Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Commit 5d7b6a6

Browse files
corrected string comparison, always use quotes
#24 https://unix.stackexchange.com/questions/131766/why-does-my-shell-script-choke-on-whitespace-or-other-special-characters the linked issue failure corner case was when the output of command contained glob characters, for ex: `a[2]` if string is unquoted on RHS of comparison operator, it is treated as glob comparison, not string comparison hence why quotes are needed here
1 parent d082d4e commit 5d7b6a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎exercises/GNU_grep/solve

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ while IFS= read -u3 -r ref_line && read -u4 -r sol_line; do
4343
sub_sol=0
4444
fi
4545

46-
if [[ $(eval "command ${ref_line:10}") == $(eval "command $sol_line") ]]; then
46+
if [[ "$(eval "command ${ref_line:10}")" == "$(eval "command $sol_line")" ]]; then
4747
(( sol_count++ ))
4848
# use color if terminal supports
4949
echo '---------------------------------------------'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /