-
Notifications
You must be signed in to change notification settings - Fork 329
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
Enable completions and add description for lfcd.fish and simplify the code #1503
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d74fee
Enable completions and add description for lfcd.fish
postsolar 7c40601
Simplify lfcd.fish
postsolar 7038f6a
lfcd.fish: unquote $argv
postsolar 7537fb1
lfcd.fish: further simplify
postsolar 1864cd0
lfcd.fish: cd only on clean exit
postsolar 4c19fe8
lfcd.fish: further simplify and add a coment on quoting semantics
postsolar bd330f5
lfcd.fish: amend comment style
postsolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if lf didn't print anything to stdout, e.g. crashed? I wouldn't want to cd to the home dir in that case.
Other than that, this lgtm; I think getting an error from
cd
when the dir is not valid is fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although something like
lfcd --doc
orlfcd -log=/dev/stdout
produces errors, do you think it falls under "I think getting an error from cd when the dir is not valid is fine"?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated code looks better to me. Apart from not cd-ing on failure, I'm more interested in that the following does not
cd
you to the home dir:Alternatively, you could insert a check that $outdir is not empty. But, at that point, you could just again check whether the dir exists. I think I'm OK either way.
Thank you!
As an aside, I checked that both of the following
cd
you to the home dir, so the fix is useful.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilyagr Good catch about
cd
-ing back to the home directory in caself
crashes, I didn't consider that. Just out of curiosity, would it not be better to quote the command substitution (i.e."$(...)"
), to ensure the output is a blank string instead of an empty list?I found the following commands result in a
cd: Empty directory '' does not exist
error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilyagr sorry, I don't follow: are you suggesting to introduce a check for whether the resulting dir variable is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@postsolar I think the point @ilyagr is trying to make is that under no circumstances should
lfcd
change to the home directory in the case thatlf
crashes or otherwise prints nothing. I think a local variable is not needed and the below should work:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@postsolar, I'm sorry I missed your question. I think @joelim-work covered what my concern was. I also believe the command he suggested should work fine. Thanks Joe!
One other thing I would add is a comment before that line, along the lines of:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelim-work @ilyagr thank you for clarifying! I updated the code and added a comment