3 ms·
In "rather than" part > echo "mystr" # no split You probably meant to include $ echo "$mystr" # no split Still, echo is not good for these examples as fo
by acqq 7y ago
In "rather than" part
> echo "mystr" # no split
You probably meant to include $
echo "$mystr" # no split
Still, echo is not good for these examples as for it the split doesn't matter and can't be detected, whereas for other commands (or even calls of functions) it indeed can matter.
This example, I think, illustrates the differences between quoted and unquoted use of $name (as present in the current shells) better (to those who aren't familiar with the nuances of shells):
f() {
echo "param 1: |$1|"
echo "param 2: |$2|"
echo "param 3: |$3|"
}
x=
y="55 66"
f "$x" "$y"
echo
f $x $y
#Output is:
#param 1: ||
#param 2: |55 66|
#param 3: ||
#
#param 1: |55|
#param 2: |66|
#param 3: ||
- chubot 7y agoYes that was a typo (too late to fix it, oops) BTW, the fact that shell splits and echo joins is VERY confusing to a beginner. For example: mystr='a b c' # two spaces between each $ echo $mystr a b c # why is there only one space? I think this was "feature" during the times when it was OK to write C code like: char line[100]; // truncates lines longer than 100 chars But it's no longer OK! Filenames contain spaces, etc.