mirror of
https://github.com/samsonjs/csc360-a1-shell.git
synced 2026-03-30 09:35:49 +00:00
Fix tilde user expansion
This commit is contained in:
parent
826b4d5594
commit
52ef7cb7f5
1 changed files with 6 additions and 1 deletions
|
|
@ -68,7 +68,12 @@ module Shell
|
|||
found_glob_char = word && word =~ /[*?\[]/ # must be unquoted
|
||||
# Expand tildes at the beginning of unquoted words.
|
||||
if word && at_word_start
|
||||
field.sub!(/^~/, Dir.home)
|
||||
field.sub!(/^~([^\/]*)/) do
|
||||
user = Regexp.last_match(1)
|
||||
user.empty? ? Dir.home : Dir.home(user)
|
||||
rescue ArgumentError
|
||||
"~#{user}"
|
||||
end
|
||||
end
|
||||
at_word_start = false
|
||||
if sep
|
||||
|
|
|
|||
Loading…
Reference in a new issue