nojhan/dotfiles

Watch out for Bash word splitting

Opened this issue · 1 comments

Hey, I was browsing your really interesting dotfiles and noticed that there are several instances of incorrect word splitting in the .bashrc file. For instance

dotfiles/.bashrc

Lines 64 to 70 in 7044573

# move to ~/.Trash instead of rm a file
function del()
{
for i in $* ; do
mv $i ~/.local/share/Trash/files/
done
}

should be written as

# move to ~/.Trash instead of rm a file
function del()
{
    for i in "$@" ; do
        mv "$i" ~/.local/share/Trash/files/
    done
}

in order to handle paths containing whitespaces. There are a lot of other potentially dangerous similar occurrences.

I recommend you check .bashrc and other related files with ShellCheck: it's really good at spotting this bugs.