diff options
| author | pml68 <contact@pml68.dev> | 2025-04-18 02:10:20 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-18 02:10:20 +0200 |
| commit | aa5a3c8120790df74f106b2c9145edae07800bb1 (patch) | |
| tree | 00f65c9660309b5d7d75e0f822f94a4fcb042e6f | |
| parent | fix: so `~` isn't expanded in `"` strings (diff) | |
| download | aur-aa5a3c8120790df74f106b2c9145edae07800bb1.tar.gz | |
feat: enable ShellCheck analysis
Diffstat (limited to '')
| -rwxr-xr-x | aur | 15 | ||||
| -rw-r--r-- | aur-completion.bash | 6 | ||||
| -rw-r--r-- | aur.completor.bash | 5 |
3 files changed, 14 insertions, 12 deletions
@@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/bash _help() { - echo "Usage: $(basename $0) [OPTIONS]" + echo "Usage: $(basename "$0") [OPTIONS]" echo "" echo "Options:" echo " <pkg1 pkg2 ...> Download and install/update the specified packages." @@ -17,7 +17,9 @@ _help() { } _update() { - for dir in $(ls -d ~/.aur/*); do + for dir in ~/.aur/*; do + [[ -e "$dir" ]] || break + if [[ $(cd "$dir" && git pull) != "Already up to date." ]] || [[ $1 == "-f" ]] || [[ "$dir" == *-git && $1 == "-g" ]]; then (cd "$dir" && makepkg -si ; _clean) fi @@ -31,8 +33,7 @@ _clean() { _update_or_install() { for package in "$@"; do - cd ~/.aur/"$package" - if [[ $? -eq 0 ]]; then + if cd ~/.aur/"$package"; then (git pull && makepkg -si ; _clean) else (git clone "https://aur.archlinux.org/$package" ~/.aur/"$package" && cd ~/.aur/"$package" && makepkg -si ; _clean) @@ -49,8 +50,8 @@ if [[ -n $1 ]]; then _update -f ;; --config | -c) - packages=`cat $2 | tr '\n' ' '` - aur $packages + packages=$(tr '\n' ' ' < "$2") + _update_or_install "$packages" ;; --git | -g) _update -g diff --git a/aur-completion.bash b/aur-completion.bash index 554e106..3644e85 100644 --- a/aur-completion.bash +++ b/aur-completion.bash @@ -17,8 +17,8 @@ _aur_comp_cmd_opts=( -h --help -l --list -f --force -g --git -c --config ) _aur_comp_reply_aur_pkgs () { - pkgs=`basename -a ~/.aur/*/ | paste -d ' ' -s -`; - COMPREPLY=($(compgen -W "$pkgs" -- "$cur")) + pkgs=$(basename -a ~/.aur/*/ | paste -d ' ' -s -); + COMPREPLY=("$(compgen -W "$pkgs" -- "$cur")") } _aur_comp_reply_dirs () @@ -50,7 +50,7 @@ _aur_comp_reply_list () { local IFS=', '; local array_list="" array_name; - for array_name in $@; + for array_name in "$@"; do array_list="$array_list \${${array_name}[*]}"; done; diff --git a/aur.completor.bash b/aur.completor.bash index c7513ed..48c6e8b 100644 --- a/aur.completor.bash +++ b/aur.completor.bash @@ -1,3 +1,4 @@ +# shellcheck disable=SC2034 output=aur-completion.bash cmd=aur cmd_args=@aur_pkgs @@ -11,7 +12,7 @@ cmd_opts=( ) reply_aur_pkgs() { - pkgs=`basename -a ~/.aur/*/ | paste -d ' ' -s -` + pkgs=$(basename -a ~/.aur/*/ | paste -d ' ' -s -) - COMPREPLY=( $(compgen -W "$pkgs" -- "$cur") ) + COMPREPLY=( "$(compgen -W "$pkgs" -- "$cur")" ) } |
