module UserShell
Constants
- VERSION
Public Class Methods
path(user=nil)
click to toggle source
Get the shell path for the specified user, defaults to current user
@param user [String] optional The target user
# File lib/usershell.rb, line 9 def self.path(user=nil) user ||='`whoami`' user_id = %x(id -u #{user}).to_i raise UserNotFoundError.new('User not found.') unless user_id > 0 if RbConfig::CONFIG['host_os'] =~ /darwin|mac os/ shell = %x(dscl . -read /Users/#{user} UserShell) shell.split(/\s/).last else shell = %x(getent passwd #{user}) shell.split(':').last.strip end end