I'm trying to write a script to tailor my dotfile setup to each machine using git update-index -skip-worktree
but it keeps chopping up the paths. I'm passing arrays starting with commands where every other value in the array is a file or directory path being tracked by git. here is a snippet of the code
fish=("fish" "$XDG_CONFIG_HOME/fish")
gtk=("gtk-launch" "$XDG_CONFIG_HOME/gtk-3.0")
i3=("i3-config-wizard" "$XDG_CONFIG_HOME/i3")
check_install() {
for var in "$@"
do
echo ${var[0]}
if ! [ -x "$(command -v ${var[0]})" ]; then
for path in "${var[@]:1}"
do
echo locally untracking $path
git update-index --skip-worktree "$path"
rm -r "$path"
done
fi
done
}
check_install $fish
check_install $gtk
check_install ${i3[@]}
the output for these entries
locally untracking ish
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
rm: cannot remove 'ish': No such file or directory
gtk-launch
i3-config-wizard
locally untracking 3-config-wizard
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
rm: cannot remove '3-config-wizard': No such file or directory
/i3
locally untracking i3
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
rm: cannot remove 'i3': No such file or directory
urxvt
I'm relatively new to functions in bash so I imagine the function isn't doing exactly what I expect. also if you guys have a better idea about how to go about this, feel free to mention it.
$array
is equivalent to${array[0]}
- to pass all the elements of arrayfish
as positional parameters to your function, you probably wantcheck_install "${fish[@]}"
and so on