Zrobiłem więc skrypt bash, który działa idealnie na MAC, ale w systemie Windows nawet z zainstalowanym cygwin i CURL nie działa, oto błędy, które otrzymuję
$ ./r.bash
Project name:
imiodrag
': not a valid identifiertheme_name
: No such file or directory
mkdir: cannot create directory `\r': File exists
>>>>>>>>>>Downloading wordpress...
Warning: Failed to create the file latest.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
158 158 0 158 0 0 531 0 --:--:-- --:--:-- --:--:-- 531
curl: (23) Failed writing body (0 != 8)
tar (child): latest.tar.gz\r: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
rm: cannot remove `latest.tar.gz\r': No such file or directory
>>>>>>>>>>Moving files...
mv: cannot stat `start-project/wp-base/': No such file or directory
: No such file or directorycontent/themes/
: No such file or directoryib/
>>>>>>>>>>Now downloading jquery...
Warning: Failed to create the file jquery-latest.min.js
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
1 93436 1 1127 0 0 17888 0 0:00:05 --:--:-- 0:00:05 17888
curl: (23) Failed writing body (0 != 1127)
: No such file or directory./
' is not a git command. See 'git --help'.
Did you mean this?
init
' did not match any files
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'Lili@Lili-PC.(none)')
: No such file or directory./../../
A oto skrypt:
#!/bin/bash
echo ""
echo "Project name: "
read theme_name
cd "../"
mkdir "$theme_name"
cd "$theme_name"
echo ">>>>>>>>>>Downloading wordpress..."
echo ""
curl -O http://wordpress.org/latest.tar.gz
tar --strip-components=1 -zxf latest.tar.gz
rm latest.tar.gz
cd "../"
echo ">>>>>>>>>>Moving files..."
echo ""
mv start-project/wp-base/ "$theme_name/wp-content/themes/$theme_name"
cd "$theme_name/wp-content/themes/$theme_name"
cd js/lib/
echo ">>>>>>>>>>Now downloading jquery..."
echo ""
curl -O http://code.jquery.com/jquery-latest.min.js
cd ../../
git init
git add .
git commit -a -m "First commit"
cd ../../../../
rm -rf start-project
Dlaczego więc nie działa w systemie Windows? Jestem na Windows 7 64bit Ultimate
bash
script
shell-script
Uffo
źródło
źródło
Odpowiedzi:
Cygwin wymaga zakończenia linii uniksowych, jak już wspomniano. Dlatego zamiast kończyć każdą linię za pomocą linii powrotu karetki (CRLF), musisz zakończyć każdą linię tylko nową linią (LF) AKA Newline.
Wiele edytorów tekstu pozwala konwertować zakończenia linii. Sam Cygwin może konwertować plik za pomocą narzędzia wiersza poleceń
d2u
.źródło