Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--help with other arguments makes directories #285

Open
wasv opened this issue Aug 6, 2022 · 1 comment
Open

--help with other arguments makes directories #285

wasv opened this issue Aug 6, 2022 · 1 comment

Comments

@wasv
Copy link

wasv commented Aug 6, 2022

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

@mat-m
Copy link
Contributor

mat-m commented Jun 25, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants