Reputation: 149
My terminal's character encoding is set to UTF-8
. I went into the terminal program's Profile Preferences / Compatibility and clicked Reset Compatibility Options to Defaults
.
I ssh'd to another machine using this terminal window.
I ran vi
and typed in the following script in by hand (to avoid any unexpected hidden special characters) on that machine. Then I ran it and got syntax error near unexpected token <<<
#!/bin/bash
cd "$1"
if [ $? -ne 0 ]; then
printf 'cd fail'
exit 1
fi
while read name
do
printf 'item: [%s]\n' "$name"
done <<< "$(stat -t ./* | awk -F' ' '{print $13 " " $1}' | sort -r | awk -F' ' '{print $2}')"
This test machine has /bin/bash
... also /bin/sh
is a link to /bin/bash
. /bin/bash --version
says GNU bash, version 2.05a.0(3)-release (i686-pc-linux-gnu)
I can disconnect from that test machine and in the same terminal window type the same script by hand on my machine and it runs fine. On my machine, /bin/bash --version
says GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
What's causing the syntax error on the test machine? Is <<<
not supported in that earlier version of Bash?
Upvotes: 0
Views: 62
Reputation: 54495
sure - that feature came in with 2.05b which git shows as July 2002, while 2.05a was November 2001.
bash's developer doesn't put dates in the changelog, but with some patience you can see the changes in git CHANGES
Upvotes: 1