Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_init_eval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_init_emits_bash_function_with_path
assert_match(/try\(\) \{/, stdout)
assert_match(/cd --path \"#{Regexp.escape(File.expand_path(dir))}\"/, stdout)
assert_match(/case \"\$cmd\" in/m, stdout)
assert_match(/\*" \&\& "\*\) eval \"\$cmd\" ;;/, stdout)
assert_match(/\*\"\&\&\"\*\) eval \"\$cmd\" ;;/, stdout)
# After the case, wrapper prints the command for shell-neutral usage.
# Accept either printf or echo implementations.
assert_match(/(printf %s \"\$cmd\"|echo \"\$cmd\")/, stdout)
Expand All @@ -29,7 +29,7 @@ def test_init_emits_fish_function_with_path
assert_match(/^function try/m, stdout)
assert_match(/cd --path \"#{Regexp.escape(File.expand_path(dir))}\"/, stdout)
assert_match(/string collect\)/, stdout)
assert_match(/string match -r ' \&\& ' -- \$cmd/, stdout)
assert_match(/string match -r '\&\&' -- \$cmd/, stdout)
end
end
end
4 changes: 2 additions & 2 deletions try.rb
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def cmd_init!(args, tries_path)
rc=$?
if [ $rc -eq 0 ]; then
case "$cmd" in
*" && "*) eval "$cmd" ;;
*"&&"*) eval "$cmd" ;;
*) printf %s "$cmd" ;;
esac
else
Expand All @@ -906,7 +906,7 @@ def cmd_init!(args, tries_path)
end
set -l rc $status
if test $rc -eq 0
if string match -r ' && ' -- $cmd
if string match -r '&&' -- $cmd
eval $cmd
else
printf %s $cmd
Expand Down