Skip to content

Commit

Permalink
fix: quote if test $foo to prevent "test: Missing argument at index…
Browse files Browse the repository at this point in the history
  • Loading branch information
edouard-lopez committed Jan 23, 2024
1 parent b7d5719 commit a4e6b25
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion functions/_pure_is_inside_container.fish
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function _pure_is_inside_container \

set --local os_name (uname -s)
# echo $os_name
if test $os_name = Linux
if test "$os_name" = Linux
if _pure_detect_container_by_cgroup_method $cgroup_namespace
return $success
end
Expand Down
6 changes: 3 additions & 3 deletions functions/_pure_parse_directory.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ function _pure_parse_directory \

set --local folder (fish_prompt_pwd_dir_length=$pure_shorten_prompt_current_directory_length prompt_pwd)

if test -n "$max_path_length";
if test (string length $folder) -gt $max_path_length;
if test -n "$max_path_length"
if test (string length $folder) -gt $max_path_length
# If path exceeds maximum symbol limit, force fish path formating function to use 1 character
set folder (fish_prompt_pwd_dir_length=1 prompt_pwd)
end
end

if test $pure_truncate_prompt_current_directory_keeps -ge 1
if test "$pure_truncate_prompt_current_directory_keeps" -ge 1
set folder (
string split '/' $folder \
| tail -n $pure_truncate_prompt_current_directory_keeps \
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/functions/kubectl.mock.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ function kubectl \
topcommand \
subcommand

if test $topcommand = config
if test "$topcommand" = config
if test $subcommand = current-context
echo my-context
end
if test $subcommand = view
if test "$subcommand" = view
echo my-namespace
end
else
Expand Down
34 changes: 21 additions & 13 deletions tools/installer.fish
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function pure_fetch_source
set --local package "https://github.com/pure-fish/pure/archive/master.tar.gz"
mkdir -p $PURE_INSTALL_DIR

command curl --silent --show-error --location "$package" | command tar -xzf- -C $PURE_INSTALL_DIR --strip-components=1; or begin;
command curl --silent --show-error --location "$package" | command tar -xzf- -C $PURE_INSTALL_DIR --strip-components=1; or begin
printf "%sError: fetching Pure sources failed%s" "$color_error" "$color_normal"
return 1
end
Expand All @@ -46,7 +46,8 @@ function pure_backup_existing_theme
set --local backup_prompt $old_prompt.ignore

if test -f "$old_prompt"
mv "$old_prompt" "$backup_prompt"; pure_exit_symbol $status
mv "$old_prompt" "$backup_prompt"
pure_exit_symbol $status
printf "\tPrevious config saved to: %s%s%s." "$color_white" "$backup_prompt" "$color_normal"
end
end
Expand All @@ -55,9 +56,9 @@ function pure_enable_autoloading
printf "\tEnabling autoloading for pure's functions on shell init"
touch "$FISH_CONFIG_DIR/config.fish"
if not grep -q "pure.fish" $FISH_CONFIG_DIR/config.fish
echo "# THEME PURE #" >> $FISH_CONFIG_DIR/config.fish
echo "set fish_function_path $PURE_INSTALL_DIR/functions/" '$fish_function_path' >> $FISH_CONFIG_DIR/config.fish
echo "source $PURE_INSTALL_DIR/conf.d/pure.fish" >> $FISH_CONFIG_DIR/config.fish
echo "# THEME PURE #" >>$FISH_CONFIG_DIR/config.fish
echo "set fish_function_path $PURE_INSTALL_DIR/functions/" '$fish_function_path' >>$FISH_CONFIG_DIR/config.fish
echo "source $PURE_INSTALL_DIR/conf.d/pure.fish" >>$FISH_CONFIG_DIR/config.fish
end
end

Expand Down Expand Up @@ -97,7 +98,7 @@ function pure_error
end

function pure_exit_symbol
if test $argv[1] -eq 0
if test "$argv[1]" -eq 0
pure_success
else
pure_error
Expand All @@ -108,11 +109,18 @@ function install_pure
printf "Installing Pure theme\n"
pure_set_fish_config_path $argv
pure_set_pure_install_path $argv
pure_scaffold_fish_directories; pure_exit_symbol $status
pure_fetch_source; pure_exit_symbol $status
pure_backup_existing_theme; pure_exit_symbol $status
pure_enable_autoloading; pure_exit_symbol $status
pure_symlinks_assets; pure_exit_symbol $status
pure_enable_theme; pure_exit_symbol $status
pure_clean_after_install; pure_exit_symbol $status
pure_scaffold_fish_directories
pure_exit_symbol $status
pure_fetch_source
pure_exit_symbol $status
pure_backup_existing_theme
pure_exit_symbol $status
pure_enable_autoloading
pure_exit_symbol $status
pure_symlinks_assets
pure_exit_symbol $status
pure_enable_theme
pure_exit_symbol $status
pure_clean_after_install
pure_exit_symbol $status
end

0 comments on commit a4e6b25

Please sign in to comment.