-
-
Notifications
You must be signed in to change notification settings - Fork 21
mc-wrapper: fish shenanigans #4726
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mc-wrapper.csh | ||
mc-wrapper.sh | ||
mc-wrapper.* | ||
!mc-wrapper.*.in | ||
mc.csh | ||
mc.sh | ||
mc.fish |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
if set -q MC_TMPDIR | ||
set MC_PWD_FILE (mktemp $MC_TMPDIR/mc.pwd.XXXXXX) | ||
else if set -q TMPDIR | ||
set MC_PWD_FILE (mktemp $TMPDIR/mc.pwd.XXXXXX) | ||
else | ||
set MC_PWD_FILE (mktemp /tmp/mc.pwd.XXXXXX) | ||
end | ||
|
||
@bindir@/mc -P "$MC_PWD_FILE" $argv || true | ||
|
||
if test -r "$MC_PWD_FILE" | ||
set MC_PWD (cat $MC_PWD_FILE) | ||
if test -n "$MC_PWD" && test $MC_PWD != $PWD && test -d $MC_PWD | ||
cd $MC_PWD || true | ||
end | ||
set -e MC_PWD | ||
end | ||
|
||
rm -f $MC_PWD_FILE | ||
set -e MC_PWD_FILE |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function mc --description 'Visual shell for Unix-like systems - fish wrapper' | ||
source @pkglibexecdir@/mc-wrapper.fish $argv | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,10 @@ script that automatically changes the current directory of the shell to | |
the last directory Midnight Commander was in. Source the file | ||
.B %pkglibexecdir%/mc.sh | ||
(bash and zsh users) or | ||
.B %libexecdir%/mc.csh | ||
(tcsh users) respectively to define | ||
.B %pkglibexecdir%/mc.csh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually there's another issue:
I'm building with
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. found it, will attempt a fix |
||
(tcsh users) or | ||
.B %pkglibexecdir%/mc.fish | ||
(fish users) respectively to define | ||
.B mc | ||
as an alias to the appropriate shell script. | ||
.TP | ||
|
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.
i don't know fish syntax, but the inconsistent use of quotes around variable expansions seems ... fishy.
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.
Yeah I used the "only quote when needed" style.
Every variable in fish is an array variable, so we need to quote it for
test -r "$foo"
, lest it expand to noe argument. But if we'reguaranteed the variable is non-empty, or if the behavior for "empty
array" is fine, there's no need.
Happy to add it though, if it helps to stay closer to other integrations.
FWIW there are only three things missing from fish that prevent it from using
contrib/mc-wrapper.sh.in
as-is:foo=bar
for global assignment (foo=bar somecommand
already works)$@
unset
(simple wrapper around fish'sset -e
)The first two I have implemented in my fork for now.
It's possible to make the wrapper scripts a bit smaller, by farming
out the management of
$MC_PWD_FILE
to an external program (writtenin any language):
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.
nevermind, that shared logic won't work because stdout is captured i.e redirected
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.
Right sorry about that. It is toally unintentional glitch. I can fix that up.