From 28e32f31548fa60455fb390fcd2655a097bfe165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rory=20O=E2=80=99Kane?= Date: Tue, 13 May 2014 17:23:03 -0400 Subject: [PATCH] In jenv.fish, add flags to `set`s for safety MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `-l` where I can to avoid overwriting any global variable called `cmd`, `arg`, or `script`. I don’t use it for the second `set arg` because it will have already been set, and I’m not sure if the `if` counts as a new scope for `-l` to create a new variable. I also use `-gx` when setting `PATH` to make it global and export it, just to be sure. --- fish/jenv.fish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fish/jenv.fish b/fish/jenv.fish index 64dc7f7..85e9040 100644 --- a/fish/jenv.fish +++ b/fish/jenv.fish @@ -1,8 +1,8 @@ -set PATH $HOME/.jenv/shims $PATH +set -gx PATH $HOME/.jenv/shims $PATH command jenv rehash 2>/dev/null function jenv - set cmd $argv[1] - set arg "" + set -l cmd $argv[1] + set -l arg "" if test (count $argv) -gt 1 # Great... fish first array index is ... 1 ! set arg $argv[2..-1] @@ -10,7 +10,7 @@ function jenv switch "$cmd" case enable-plugin rehash shell shell-options - set script (jenv "sh-$cmd" "$arg") + set -l script (jenv "sh-$cmd" "$arg") eval $script case '*' command jenv $cmd $arg