arch-ppa icon indicating copy to clipboard operation
arch-ppa copied to clipboard

Repository environment variable

Open arkag opened this issue 9 years ago • 16 comments

Feature Request

I'm looking to link ~/arch-ppa/arch-ppa to my /usr/bin folder so that I can call it without needing to be in the git directory. Currently when running anything, it attempts to create all files in /usr/bin:

host@host1:~|⇒  arch-ppa list eyc
mkdir: cannot create directory ‘/usr/bin/src’: Permission denied
## Creating arch chroot ...
$ mkdir /usr/bin/chroot
mkdir: cannot create directory ‘/usr/bin/chroot’: File exists

Can you make sure it follows the symbolic link or uses a default repo directory?

arkag avatar May 19 '16 14:05 arkag

Yea, I think it was just laziness on my part to have it run in place.

How about it creates a directory in $USER/.arch-ppa by default but could be changed by command flag (or perhaps env var like you suggested)?

EnigmaCurry avatar May 19 '16 14:05 EnigmaCurry

I think default in $HOME/.arch-ppa is fine.

Really what would be cool is setting a command flag with arch-ppa setup -r $HOME/new/dir which would change the environment variable automatically.

arkag avatar May 19 '16 14:05 arkag

I'll do this.

arkag avatar May 19 '16 14:05 arkag

Cool, thanks

EnigmaCurry avatar May 19 '16 14:05 EnigmaCurry

Real quick, I've never worked on a bash script like this... Typically I throw things into main() and call the functions from there.... How are you calling everything in here?

arkag avatar May 19 '16 14:05 arkag

It's the $* bit on line 256.

EnigmaCurry avatar May 19 '16 14:05 EnigmaCurry

It takes the exact command you typed in the cli and assumes the first word is the function name and the rest as arguments to that function.

EnigmaCurry avatar May 19 '16 14:05 EnigmaCurry

Any reason we're using $* instead of $@? $@ should be used, from what I'm reading.

arkag avatar May 19 '16 15:05 arkag

Also, I've read that it's bad practice to use $var when var is set inside the script. Are you okay if I change $var to ${var} when variables in the script are called?

arkag avatar May 19 '16 15:05 arkag

I think you're right, specifically looks like we should use "$@" (with quotes):

http://stackoverflow.com/questions/12314451/accessing-bash-command-line-args-vs

Doesn't matter with the current args, but as we develop more it could become a problem.

I'll create another issue for it.

EnigmaCurry avatar May 19 '16 15:05 EnigmaCurry

I admit I'm not sure what the problem is with $ vs ${}

EnigmaCurry avatar May 19 '16 15:05 EnigmaCurry

From here:

Note that $variable is actually a simplified form of ${variable}. In contexts where the $variable syntax causes an error, the longer form may work

So it shouldn't matter, but it's better practice to use ${}.

arkag avatar May 19 '16 15:05 arkag

works for me, thanks for the docs.

EnigmaCurry avatar May 19 '16 15:05 EnigmaCurry

Sure thing, you okay if I put in more explicit help text? I enjoy documentation.

arkag avatar May 19 '16 15:05 arkag

yes please

EnigmaCurry avatar May 19 '16 15:05 EnigmaCurry

Covered by #6

arkag avatar May 19 '16 15:05 arkag