rcm
rcm copied to clipboard
`--help` with other arguments makes directories
When running mkrc
with --help
after a filename, the mv
help is prefixed and directories are created in the .dotfiles
directory (.rcm
in my case) with the directory names being the text of the dirname
usage message.
This is clearly not intended behavior, though it was a rather amusing bug to find. This is hopefully an easy fix, if not maybe I'll have time to take a look and open a PR someday.
Attached is a terminal log of the issue. lol-rcm.txt
Basically, wrong arguments order is not blocking. I guess it should. Below my failure to put the path at the end of the command:
➜ ~ mkrc -U .config/i3 -t i3 -v
dirname: invalid option -- 't'
Try 'dirname --help' for more information.
mv: failed to access '/home/mm/.dotfiles/-t': No such file or directory
Usage: rcup [-CfhiKkqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-U EXCL_PAT] [-u EXCL_PAT] [-x EXCL_PAT]
see rcup(1) and rcm(7) for more details
mv: cannot stat 'i3': No such file or directory
dirname: invalid option -- 'v'
Try 'dirname --help' for more information.
mv: missing destination file operand after '/home/mm/.dotfiles/-v'
Try 'mv --help' for more information.
identical /home/mm/.bin
identical /home/mm/.config/etc/home_backup.conf
'/home/mm/.dotfiles/config/i3/config' -> '/home/mm/.config/i3/config'
'/home/mm/.dotfiles/config/i3/i3blocks.conf' -> '/home/mm/.config/i3/i3blocks.conf'
[continued listing already regsitered paths]
Note that we can have no FILES at the end to scan the whole folder.
This command mkrc -U -t i3 -v .config/i3
worked as expected.
Suggestions:
- if we detect a file, check that all remaining arguments are also files (I think that was my case)
- From OP: if --help is found anywhere on the command line, process it and stop there. Seems a dedicated parsing is required for this.
I may be able to work on it during summer. @mike-burns can you validate my suggestions ?
ATB