I have this remote Bash script In GitHub that I already executed successfully line by line, several times (in different versions).
As it is quite frustrating to copy paste all lines each test, I tried to execute the remote Bash script by its raw form with curl
, but it fails in various tries:
bash <(curl -s https://raw.githubusercontent.com/benqzq/uncwe/master/install.sh)
or
curl -s https://raw.githubusercontent.com/benqzq/uncwe/master/install.sh | bash
Both failed totally after about 3 seconds with the error:
/dev/fd/63: line 7: $'\r': command not found
I theorized I might need to translate out all carriage returns, hence tried:
curl -s https://raw.githubusercontent.com/benqzq/uncwe/master/install.sh | tr -d '\r' | bash
This brought partial execution of the script. For example, while apt-get install
, export
,git clone
, rm -rf ${repo}/.git/
, and a few other operations went fine, the wget
/unzip
and processing of a few files with leading tabs failed to be processed correctly.
I thought it might be that GitHub GUI changes leading whitespaces from tab to space and vice versa, in some sections in the code, so I tried to change all leading whitespaces into tabulations:
curl -s https://raw.githubusercontent.com/benqzq/uncwe/master/install.sh | sed "s/^ */\t/" | tr -d '\r' | bash
The result was seemingly identical to the previous one.
Due these 4 ways fail, I wonder what else is available. Sadly I've yet to find other examples in Google.
Maybe I'm having these problems because I usually work from Windows 10 and carriage returns are added to each file, but than one could ask why did "translating them out" as in of the code examples resulted in bad execution.
curl -s -L https://.... | tr -d '\r' | bash -x
, which show the commands being executed, follows redirections and removes carridge returns. The raw content does seem to have lines ending \r\n, so you will need to remove the \r. Bash is not python, you don't need to worry about indentation. Can you edit your question to explain what is failing once you have removed the \r, or clarify that you want to know why things fail if you don't remove the \r.