bin: do not call any variable 'path'

That somehow overrides the PATH variable upon copying out...
This commit is contained in:
xeruf 2022-01-30 22:17:45 +01:00
parent 10819be48c
commit 8af2f94cbe
4 changed files with 30 additions and 28 deletions

View File

@ -226,7 +226,7 @@ alias grpc='grep --color=auto --line-number --binary-files=without-match --direc
# Grep recursively and paginate
grpr() { grp --color=always --recursive $(echo $DIRS_IGNORE | sed 's/-x/--exclude-dir/g') "$@" | less -F; }
# Grep in shell config files
grsh() { grpr "$@" $HOME/.{ba,z}sh* $HOME/.local/bin $CONFIG_SHELLS $CONFIG_ZSH }
grsh() { grpr --no-ignore-case "$@" $HOME/.{ba,z}sh* $HOME/.local/bin $CONFIG_SHELLS $CONFIG_ZSH }
# Recover stray swap files from neovim
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs --no-run-if-empty nvim"

View File

@ -14,8 +14,8 @@ df --output="source,avail" -h $(test -n "$local" && echo ".") "$dir"
highlight "cleaning home"
for f in ${_clean_home[@]}
do path="$dir/$f"
test -f "$path" || test -d "$path" && echo "Removing superfluous $path" && rm -rf $i "$path"
do file="$dir/$f"
test -f "$file" || test -d "$file" && echo "Removing superfluous $file" && rm -rf $i "$file"
done
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
find -L -maxdepth 2 -type l -printf "Removing broken symlink %p\n" -delete
@ -37,7 +37,8 @@ highlight "s :: recursively remove logs"
highlight "m :: recursively remove mac-files"
if [[ $1 =~ "m" ]]; then
find -iname '.spotlight*' -exec rm -rI {} +
find -name '__MACOSX' -print -exec rm -r {} +
find -iname '.spotlight*' -print -exec rm -rI {} +
find -name '*.DS_Store' -delete
fi

View File

@ -6,7 +6,7 @@
# optdepends: rewrite(part of my dotfiles)
for arg do
if test -r "$arg"; then
path="$(realpath "$arg")"
fullpath="$(realpath "$arg")"
name="$(basename "${path%.*}")"
namepart="$name.part"
(
@ -16,20 +16,20 @@ for arg do
fi
echo "Extracting $arg into $PWD"
case "$arg" in
(*.tar.*|*.tar) tar --extract --file "$path";;
(*.tbz2) tar xjf "$path" ;;
(*.tgz) tar xzf "$path" ;;
(*.tar.*|*.tar) tar --extract --file "$fullpath";;
(*.tbz2) tar xjf "$fullpath" ;;
(*.tgz) tar xzf "$fullpath" ;;
(*.7z|*.z01|*.zip|*.jar)
if which 7z >/dev/null
then 7z x "$path"
else unzip "$path" | rewrite
then 7z x "$fullpath"
else unzip "$fullpath" | rewrite
fi;;
(*.gz) gunzip "$path" ;;
(*.bz2) bunzip2 "$path" ;;
(*.rar) unrar x "$path" ;;
(*.deb) ar x "$path" ;;
(*.zst) unzstd "$path" ;;
(*.Z) uncompress "$path";;
(*.gz) gunzip "$fullpath" ;;
(*.bz2) bunzip2 "$fullpath" ;;
(*.rar) unrar x "$fullpath" ;;
(*.deb) ar x "$fullpath" ;;
(*.zst) unzstd "$fullpath" ;;
(*.Z) uncompress "$fullpath";;
(*) echo "'$arg' cannot be extracted by ex" >&2;;
esac
test "$(basename "$PWD")" = "$namepart" &&

View File

@ -9,22 +9,23 @@ if test "$1" = "-r"
then shift
test "$1" = "-v" && verbose=-v && shift
for arg
do path="$({ find "$(dirname "$arg")" -maxdepth 1 -name "$(basename "$arg")*" -exec realpath {} + ||
do filepath="$({ find "$(dirname "$arg")" -maxdepth 1 -name "$(basename "$arg")*" -exec realpath {} + ||
find "$MUSIC/$(dirname "$arg")" "$MUSIC/Playlists/$(dirname "$arg")" -maxdepth 1 \
-name "$(basename "$arg")*" -exec realpath {} +; } 2>/dev/null)"
test -n "$verbose" && echo "Scanning path '$path' $(
test "$arg" != "$path" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
test $(printf "$path" | wc -l) -gt 0 && printf "$path" | xargs --delim='\n' "$0" -r $verbose && continue
test -n "$path" || continue
if { file "$path" | grep -i ' playlist' || expr "$path" : ".*\.m3u8\?$"; } >/dev/null
then pushd "$(dirname "$path")" >/dev/null &&
cat "$path" | sed '/#.*/D' | xargs --delim='\n' "$0" -r $verbose &&
test -n "$verbose" && echo "Scanning path '$filepath' $(
test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
test $(printf "$filepath" | wc -l) -gt 0 && printf "$filepath" | xargs --delim='\n' "$0" -r $verbose && continue
test -n "$filepath" || continue
if { file "$filepath" | grep -i ' playlist' || expr "$filepath" : ".*\.m3u8\?$"; } >/dev/null
then pushd "$(dirname "$filepath")" >/dev/null &&
cat "$filepath" | sed '/#.*/D' | xargs --delim='\n' "$0" -r $verbose &&
popd >/dev/null
else
test -n "$verbose" &&
echo "Running find in path '$path' $(test "$arg" != "$path" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
find "$path" -iname "*.flac" -o -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.opus" | sort | while read file
do case "$path" in
echo "Running find in path '$filepath' $(test "$arg" != "$filepath" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
find "$filepath" -iname "*.flac" -o -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.opus" |
sort | while read file
do case "$filepath" in
($MUSIC/*) echo "${file#$MUSIC/}";;
(*) mkdir -p "$LINKS" &&
ln -fs "$file" "$LINKS/$(basename "$file")" &&
@ -36,7 +37,7 @@ else
test "$1" = "-q" && quiet=-q && shift
test -n "$(mpc playlist)" && next=-q
test "$1" = "--seek" && seek=-q
{ "$0" -r "$@" && mpc -q update --wait; } | #tee /tmp/mp 2>&1
( "$0" -r "$@" && mpc -q update --wait ) | #tee /tmp/mp 2>&1
xargs --delim='\n' mpc insert
mpc ${quiet:-${next:-$seek}} play
test -z "$next" || mpc ${quiet:-$seek} next