I want to ask the user of my bash script to pass a directory path as argument. Which one of the following is a good programming practice?
- Require that the user enter a trailing / (forward slash)
- Require that a user doesn't enter a trailing / (forward slash)
rsync
behaves differently in a very important way depending on the presence of trailing/
, and so in some cases you'd want to normalise for consistency, and in others you'd want to pass through cleanly to implement what the user said (if they knew they were talking torsync
).ls -l dir
behaves differently tols -l dir/
ifdir
is a symlink to a directory.