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

fix(mv): add -n option, make -f default behavior #328

Merged
merged 1 commit into from
Feb 1, 2016

Conversation

nfischer
Copy link
Member

This lets mv() have -f as the default behavior (the flag exists for legacy reasons). I introduce the -n flag, which will allow the opposite behavior. This is the default behavior on Bash.

This also introduces a modification to parseOptions(), allowing dictionaries to be specified of the following form:

options = common.parseOptions(options, {
  'f': '!no_force', // the boolean opposite of "no_force"
  'n': 'no_force'
});

The empty string will still cause no_force to default to false, as it normally would. Options prefixed with ! have the special meaning that the appearance of that commandline flag sets the option to false instead of true. So passing the -f flag will cause options.no_force to be false.

If someone passes in a flag like -fn, this will set options.no_force = true, taking whichever is last, which is consistent with most core-utils. -nf will likewise set options.no_force = false.

@nfischer nfischer mentioned this pull request Jan 31, 2016
@nfischer nfischer added fix Bug/defect, or a fix for such a problem low priority bash compat Compatibility issues with bash or POSIX behavior medium priority and removed low priority labels Jan 31, 2016
@nfischer
Copy link
Member Author

This is related to #210 (although this is the mv equivalent), and the discussion in #325. If #325 is refactored to change default behavior, then this blocks #325.

@nfischer nfischer added this to the v0.6.0 milestone Jan 31, 2016
@ariporad
Copy link
Contributor

ariporad commented Feb 1, 2016

LGTM!

ariporad added a commit that referenced this pull request Feb 1, 2016
fix(mv): add -n option, make -f default behavior
@ariporad ariporad merged commit 18d6b6d into master Feb 1, 2016
@ariporad ariporad deleted the fix-mv-semantics branch February 1, 2016 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash compat Compatibility issues with bash or POSIX behavior fix Bug/defect, or a fix for such a problem medium priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants