I have exactly these lines in my quite complex script:
echo $SHELL echo "$BASH_VERSION" echo $(which cat) echo $(alias cat 2>/dev/null) || : cat <<AAA test AAA echo 1
And it shows an error in debug log:
++++ echo /bin/bash ++++ echo '4.3.46(1)-release' +++++ which cat ++++ echo /bin/cat +++++ alias cat ++++ echo ++++ cat cat: -: No such file or directory
And when I try to repeat the same in simple script - cat works as intended and just prints "test"
(The same happens when I replace AAA with some other word. This is simple docker container from basic "ubuntu" image with some programs installed. And I am pretty sure this exact setup did work fine for some months. Maybe container just broken, but I am still interested to find root cause).
Any idea what can cause the error?
Update next day : TLDR: I believe it was some problem with docker. To address valid comments:
- usual $(cat myfile) command did work as expected from the complex script
- I am pretty sure that no hidden characters could cause the problem
- the script was complex just in amount of things it tries to do; really no hacking like dealing IFS/file-descriptors.
- /tmp was ok wtr space and permissions
- Now i remember that at some point /dev/shm was 100% filled and despite I cleaned it out - maybe that is related (corrupted something in kernel?)
Today I've booted into that container and it looks broken even more - at least all mounts look corrupted as below :
# ll ls: cannot access '_template': No such file or directory drwxr-xr-x 2 root root 4096 Apr 2 13:41 _system/ d????????? ? ? ? ? ? _template/
So I cannot run script anymore there. I will create new container and expect that it will work properly.
I believe further troubleshooting requires digging into kernel / docker logs and probably not that interesting.