do not use subshells where unnecessary

master
Alan Faubert 1 year ago
parent cd794eeed8
commit f90e56fef3

@ -29,7 +29,7 @@ while :; do
ln --relative --symbolic "$(wslpath "$(wslvar USERPROFILE)")" ~/win
;;
wsl-wsltty)
(cmd.exe /c rmdir /s /q "%APPDATA%\wsltty" 2\> nul; cmd.exe /c mklink /d "%APPDATA%\wsltty" "$root_win\wsl\wsltty")
{ cmd.exe /c rmdir /s /q "%APPDATA%\wsltty" 2\> nul; cmd.exe /c mklink /d "%APPDATA%\wsltty" "$root_win\wsl\wsltty"; }
;;
bash-profile)
ln --force --relative --symbolic bash/.profile ~/.profile
@ -41,11 +41,11 @@ while :; do
rm --force --recursive ~/.ssh &&
ln --relative --symbolic ssh/config ~/.ssh &&
chmod 600 ~/.ssh/* &&
[ -z "$root_win" ] || (cmd.exe /c rmdir /s /q "%USERPROFILE%\.ssh" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.ssh" "$root_win\ssh\config")
[ -z "$root_win" ] || { cmd.exe /c rmdir /s /q "%USERPROFILE%\.ssh" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.ssh" "$root_win\ssh\config"; }
;;
git)
ln --force --relative --symbolic git/.gitconfig ~/.gitconfig &&
[ -z "$root_win" ] || (cmd.exe /c del "%USERPROFILE%\.gitconfig" 2\> nul; cmd.exe /c mklink "%USERPROFILE%\.gitconfig" "$root_win\git\.gitconfig")
[ -z "$root_win" ] || { cmd.exe /c del "%USERPROFILE%\.gitconfig" 2\> nul; cmd.exe /c mklink "%USERPROFILE%\.gitconfig" "$root_win\git\.gitconfig"; }
;;
git-delta)
mkdir --parents ~/.bin &&
@ -53,7 +53,7 @@ while :; do
chmod +x ~/.bin/git-delta
;;
git-filter-repo)
([ -d ~/.bin/git-filter-repo ] || (mkdir --parents ~/.bin && git clone https://github.com/newren/git-filter-repo ~/.bin/git-filter-repo)) &&
{ [ -d ~/.bin/git-filter-repo ] || { mkdir --parents ~/.bin && git clone https://github.com/newren/git-filter-repo ~/.bin/git-filter-repo; }; } &&
bash/scripts/2path.sh ~/.bin/git-filter-repo/git-filter-repo
;;
git-scripts)
@ -65,8 +65,8 @@ while :; do
;;
vscode)
if [ "$root_win" ]; then
(cmd.exe /c del "%APPDATA%\Code\User\keybindings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\keybindings.json" "$root_win\vscode\keybindings.json") &&
(cmd.exe /c del "%APPDATA%\Code\User\settings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\settings.json" "$root_win\vscode\settings.json")
{ cmd.exe /c del "%APPDATA%\Code\User\keybindings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\keybindings.json" "$root_win\vscode\keybindings.json"; } &&
{ cmd.exe /c del "%APPDATA%\Code\User\settings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\settings.json" "$root_win\vscode\settings.json"; }
else
mkdir --parents ~/.config/Code/User &&
ln --force --relative --symbolic vscode/keybindings.json ~/.config/Code/User/keybindings.json &&
@ -86,7 +86,7 @@ while :; do
bash/scripts/2path.sh nodejs/scripts
;;
gcloud)
([ -d ~/.bin/gcloud ] || (mkdir --parents ~/.bin/gcloud && wget "$(curl --silent https://cloud.google.com/sdk/docs/downloads-versioned-archives | grep --only-matching 'https[^\"]*linux-x86_64.tar.gz')" --output-document=- | tar --extract --directory ~/.bin/gcloud --gzip --strip-components=1)) &&
{ [ -d ~/.bin/gcloud ] || { mkdir --parents ~/.bin/gcloud && wget "$(curl --silent https://cloud.google.com/sdk/docs/downloads-versioned-archives | grep --only-matching 'https[^\"]*linux-x86_64.tar.gz')" --output-document=- | tar --extract --directory ~/.bin/gcloud --gzip --strip-components=1; }; } &&
bash/scripts/2path.sh ~/.bin/gcloud/bin/gcloud
;;
gcloud-config)

@ -1,9 +1,11 @@
#!/bin/sh
if [ $# = 0 ]; then >&2 echo 'Arguments: <executable file>...'; exit 1; fi
dir="$PWD"
for bin in "$@"; do
(while :; do
while :; do
if [ -f node_modules/.bin/"$bin" ]; then >&2 echo Found $bin; echo alias $bin=$(readlink --canonicalize node_modules/.bin)/$bin; break; fi
if [ "$PWD" = / ]; then >&2 echo Could not find $bin; break; fi
cd ..
done)
done
cd "$dir"
done

@ -1,5 +1,6 @@
#!/bin/sh
if [ $# = 0 ]; then >&2 echo 'Arguments: <package>... [<src search root> <package>...]...'; exit 1; fi
dir="$PWD"
src_search_root=.
for pkg in "$@"; do
case "$pkg" in
@ -9,7 +10,7 @@ for pkg in "$@"; do
;;
esac
base="$(basename "$pkg")"
(while :; do
while :; do
if [ -e node_modules/"$pkg" ]; then
dest="$PWD"/node_modules/"$pkg"
cd "$src_search_root"
@ -27,5 +28,6 @@ for pkg in "$@"; do
fi
if [ "$PWD" = / ]; then >&2 echo Could not find usage of $pkg; break; fi
cd ..
done)
done
cd "$dir"
done

Loading…
Cancel
Save