Page 1 of 1

Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 4:03 pm
by davisdude
I don't have access to a Mac or Linux.
Can somebody test the bash version of this for me?

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 5:19 pm
by pgimeno
rm -rf is more or less the equivalent to rd /q /s, so it's advisable to place it at least in the first rm, to avoid displaying an error to the user when the directory doesn't exist. Also, the .git directory has write protected files, which makes rm prompt for confirmation unless -f is specified, so it's advisable to place it in the second rm too.

It lacks a line like: mv -f out.txt ../syntax/lua.vim

Just in case, it's better to stop in case a command errors, and let the user deal with the situation. That's done with set -e.

The docs should tell you to cd gen in order to run it, otherwise 'love .' won't work (that applies to the Windows version as well). Also, Linux users are not used to \ for directories.

And a minor nitpick, it's not a bash script, it's a sh script ;)

So, here's gen.sh with these changes:

Code: Select all

#!/bin/sh

set -e
rm -rf love-api
git clone https://github.com/rm-code/love-api
love .> out.txt
rm -rf love-api
mv out.txt ../syntax/lua.vim

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 5:33 pm
by davisdude
Thanks for the help! I still have a lot to learn... Thanks for noticing I left out the move as well.
In Batch I did

Code: Select all

cd %~dp0
which sets the directory to the directory of the batch file. Would this

Code: Select all

cd "$(dirname "$0")"
do the trick?
I've updated the linked file. Do you mind testing it again?

Thanks for the help.

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 5:39 pm
by RetroMan
BTW, if you install this: https://www.cygwin.com/ it creates an environment with a bash interpreter in it. Simple download and install, won't litter your hard drive with junk. You just open a terminal window and there ya go ... :)

Cheers.

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 5:46 pm
by davisdude
Thanks, that sounds a lot more convenient than asking other people to do it for me.

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 5:58 pm
by pgimeno
davisdude wrote:In Batch I did

Code: Select all

cd %~dp0
which sets the directory to the directory of the batch file. Would this

Code: Select all

cd "$(dirname "$0")"
do the trick?
Missed that, sorry. I didn't know what %~dp0 meant. Yes, that should work.
davisdude wrote:I've updated the linked file. Do you mind testing it again?
It's working fine now :nyu:

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 6:04 pm
by davisdude
Thanks again

Re: Can somebody test this bash script for me?

Posted: Sun Jan 03, 2016 6:25 pm
by Kingdaro
For future reference, you can also use Cygwin to use shell scripts on Windows. Git for windows also comes with Git Bash, which can be used to run shell scripts as well.

EDIT: Apparently I hadn't refreshed this page for a while. Oh well.