Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A curl utility problem that strongly effects my work with Bash on Windows #2939

Closed
ghost opened this issue Feb 12, 2018 · 7 comments
Closed

Comments

@ghost
Copy link

ghost commented Feb 12, 2018

This is not a WSL problem per se, but deals heavily with Bash in Windows (Linux users seem not to encounter this). It roams my work with WSL and avoids me from working with curl smoothly:

I have this [remote Bash script][1] 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.

@therealkenc
Copy link
Collaborator

/dev/fd/63: line 7: $'\r': command not found

#2365 #2551

Run it though dos2unix before feeding it to bash.

@ghost
Copy link
Author

ghost commented Feb 12, 2018

@therealkenc I can't test at the moment but I assume you meant to pipe it through dos2unix before feeding it to bash?

@therealkenc
Copy link
Collaborator

I assume you meant to pipe it through dos2unix

Sure, if you want to be all fancy about it.

@ghost
Copy link
Author

ghost commented Feb 13, 2018

I now saw that dos2unix isn't native in Ubuntu. Crap. I than have execute apt-get install dos2unix before running the curl, this results in a long ugly command in deployment:

apt-get install dos2unix -y && curl -s https://raw.githubusercontent.com/benqzq/uncwe/master/install.sh | dos2unix | bash

@benhillis
Copy link
Member

Or you could reupload your script atfter running dos2unix on it.

@benhillis
Copy link
Member

git clone https://github.com/benqzq/ulcwe.git
cd ulcwe
sudo apt install dos2unix
dos2unix install.sh
git commit -a -m "change line endings to unix-style"
git push

@ghost
Copy link
Author

ghost commented Feb 14, 2018

AFAIK if I run the install.sh script with curl before installing dos2unix, it will fail, so dos2unix should be installed before the curl.

Thanks anyway,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants