Can somebody test this bash script for me?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Can somebody test this bash script for me?

Post by davisdude »

I don't have access to a Mac or Linux.
Can somebody test the bash version of this for me?
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
pgimeno
Party member
Posts: 3655
Joined: Sun Oct 18, 2015 2:58 pm

Re: Can somebody test this bash script for me?

Post 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
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Can somebody test this bash script for me?

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
RetroMan
Prole
Posts: 16
Joined: Fri Oct 10, 2008 7:05 pm

Re: Can somebody test this bash script for me?

Post 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.
Old programmers never die, they just get disassembled...
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Can somebody test this bash script for me?

Post by davisdude »

Thanks, that sounds a lot more convenient than asking other people to do it for me.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
pgimeno
Party member
Posts: 3655
Joined: Sun Oct 18, 2015 2:58 pm

Re: Can somebody test this bash script for me?

Post 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:
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Can somebody test this bash script for me?

Post by davisdude »

Thanks again
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Can somebody test this bash script for me?

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest