nojhan / dotfiles

My config files
42 stars 3 forks source link

Watch out for Bash word splitting #5

Open FedericoStra opened 2 years ago

FedericoStra commented 2 years ago

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 https://github.com/nojhan/dotfiles/blob/7044573f7e82c8cec9171f4a3f463bb80197c94a/.bashrc#L64-L70 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.

nojhan commented 2 years ago

Thanks, you're definitely right, I should have updated that years ago :)

On Tue, Feb 8, 2022 at 11:19 AM Federico Stra @.***> wrote:

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

https://github.com/nojhan/dotfiles/blob/7044573f7e82c8cec9171f4a3f463bb80197c94a/.bashrc#L64-L70 should be written as

move to ~/.Trash instead of rm a filefunction 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 https://www.shellcheck.net/: it's really good at spotting this bugs.

— Reply to this email directly, view it on GitHub https://github.com/nojhan/dotfiles/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACFSUOCKK7RDSLBWF2CKRDU2DUZLANCNFSM5NZ77SHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>