Skip to content

Ticket #4726: add mc-wrapper for fish shell #4730

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions contrib/.gitignore
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.fish
mc.sh
20 changes: 18 additions & 2 deletions contrib/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@

noinst_DATA = README.xterm

SCRIPTS_IN = mc.csh.in mc.sh.in mc-wrapper.csh.in mc-wrapper.sh.in
SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh
SCRIPTS_IN = \
mc.csh.in \
mc.sh.in \
mc-wrapper.csh.in \
mc-wrapper.fish.in \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I intentionally did not include the fish lines in this commit because they belong in the commit that adds the referenced fish files.
Of course the advantage from the separate commit is fairly small here so both could be combined into a single commit also.

mc-wrapper.sh.in
SCRIPTS_OUT = \
mc.csh \
mc.sh \
mc-wrapper.csh \
mc-wrapper.fish \
mc-wrapper.sh

pkglibexec_SCRIPTS = $(SCRIPTS_OUT)

Expand All @@ -20,12 +30,18 @@ EXTRA_DIST = \
mc.csh: $(top_builddir)/config.status $(srcdir)/mc.csh.in
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.csh.in > mc.csh

mc.fish: $(top_builddir)/config.status $(srcdir)/mc.fish.in
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.fish.in > mc.fish

mc.sh: $(top_builddir)/config.status $(srcdir)/mc.sh.in
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.sh.in > mc.sh

mc-wrapper.csh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.csh.in
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.csh.in > mc-wrapper.csh

mc-wrapper.fish: $(top_builddir)/config.status $(srcdir)/mc-wrapper.fish.in
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.fish.in > mc-wrapper.fish

mc-wrapper.sh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.sh.in
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.sh.in > mc-wrapper.sh

1 change: 1 addition & 0 deletions contrib/mc-wrapper.csh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ else
setenv MC_PWD_FILE "`mktemp '/tmp/mc.pwd.XXXXXX'`"
endif

# Propagate mc exit code outside the wrapper
@bindir@/mc -P "$MC_PWD_FILE" $*

if (-r "$MC_PWD_FILE") then
Expand Down
20 changes: 20 additions & 0 deletions contrib/mc-wrapper.fish.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set --local MC_PWD_FILE
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

# Propagate mc exit code outside the wrapper
@bindir@/mc -P "$MC_PWD_FILE" $argv
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not actually propagate the exit code beyond line 13.
If we do want to propagate it (which seems like a good idea),
then we should be doing something like this (untested)
but probably for all shells

diff --git a/contrib/mc-wrapper.sh.in b/contrib/mc-wrapper.sh.in
index 399b38a892..1a8200b5de 100644
--- a/contrib/mc-wrapper.sh.in
+++ b/contrib/mc-wrapper.sh.in
@@ -6,7 +6,8 @@
 	MC_PWD_FILE="`mktemp "/tmp/mc.pwd.XXXXXX"`"
 fi
 
-@bindir@/mc -P "$MC_PWD_FILE" "$@" || true
+MC_STATUS=0
+@bindir@/mc -P "$MC_PWD_FILE" "$@" || MC_STATUS=$?
 
 if test -r "$MC_PWD_FILE"; then
 	MC_PWD="`cat "$MC_PWD_FILE"`"
@@ -18,3 +19,4 @@
 
 rm -f "$MC_PWD_FILE"
 unset MC_PWD_FILE
+eval "unset MC_STATUS; exit $MC_STATUS"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the comment was written assuming set -e, which is not the usual behavior, and even in that case we want to clean up.. though that's an edge case of an edge case


if test -r "$MC_PWD_FILE"
set --local MC_PWD (cat $MC_PWD_FILE)
if test -n $MC_PWD && test $MC_PWD != $PWD && test -d $MC_PWD
cd $MC_PWD || true
end
end

rm -f $MC_PWD_FILE
1 change: 1 addition & 0 deletions contrib/mc-wrapper.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ else
MC_PWD_FILE="`mktemp "/tmp/mc.pwd.XXXXXX"`"
fi

# Propagate mc exit code outside the wrapper
@bindir@/mc -P "$MC_PWD_FILE" "$@"

if test -r "$MC_PWD_FILE"; then
Expand Down
3 changes: 3 additions & 0 deletions contrib/mc.fish.in
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
6 changes: 4 additions & 2 deletions doc/man/es/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ usada directamente, sino desde un guión de shell adecuado, para dejar
como directorio activo el directorio que estaba en uso dentro de
Midnight Commander. Consúltese en los archivos
.B %pkglibexecdir%/mc.sh
(usuarios de bash y zsh) y
(usuarios de bash y zsh),
.B %pkglibexecdir%/mc.csh
(usuarios de tcsh) la manera de definir
(usuarios de tcsh) y
.B %pkglibexecdir%/mc.fish
(usuarios de fish) la manera de definir
.B mc
como un alias para el correspondiente guión de shell.
.TP
Expand Down
6 changes: 4 additions & 2 deletions doc/man/hu/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ helyett a Midnight Commander által utoljára meglátogatott könyvtárra való
Fjerdingstad\-nek és Sergey\-nek közreműködésükért). Kérlek, ne csinálj
szó szerinti másolatot a funkció beállításairól. A fájlok forrása a
.I %pkglibexecdir%/mc.sh
(bash és zsh felhasználóknak), illetőleg a
(bash és zsh felhasználóknak),
.I %pkglibexecdir%/mc.csh
(tcsh felhasználóknak) fájl. Ilyenkor, amikor a funkció beállításokat
(tcsh felhasználóknak) illetőleg a
.I %pkglibexecdir%/mc.fish
(fish felhasználóknak) fájl. Ilyenkor, amikor a funkció beállításokat
változtatod, a profil értékeket nem szükséges megváltoztatnod, csak
arról gondoskodj, hogy az MC\-t ne fordítsd eltérő beállításokkal.
.PP
Expand Down
6 changes: 4 additions & 2 deletions doc/man/it/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ utilizzata da una speciale funzione shell che imposti automaticamente
l'ultima directory corrente della shell come l'ultima directory in cui
stava il Midnight Commander. Prelevate i file
.B %pkglibexecdir%/mc.sh
(utenti bash e zsh) o rispettivamente
(utenti bash e zsh),
.B %pkglibexecdir%/mc.csh
(utenti tcsh) per definire
(utenti tcsh) o rispettivamente
.B %pkglibexecdir%/mc.fish
(utenti fish) per definire
.B mc
come un alias allo script di shell appropriato.
.TP
Expand Down
8 changes: 5 additions & 3 deletions doc/man/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ not meant to be used directly. Instead, it's used from a special shell
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
(bash and zsh users),
.B %pkglibexecdir%/mc.csh
(tcsh users), or
.B %pkglibexecdir%/mc.fish
(fish users) respectively to define
.B mc
as an alias to the appropriate shell script.
.TP
Expand Down
4 changes: 3 additions & 1 deletion doc/man/ru/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ Commander.
.IP
Для того чтобы эта функция была определена, используйте файл
.B %pkglibexecdir%/mc.sh
для оболочек bash и zsh, а для оболочки tcsh соответственно файл
для оболочек bash и zsh, или для оболочки tcsh файл
.B %pkglibexecdir%/mc.csh
а для оболочки fish соответственно файл
.B %pkglibexecdir%/mc.fish
.TP
.I \-s, \-\-slow
Включает медленный режим терминала, в котором программа выводит меньше
Expand Down
4 changes: 3 additions & 1 deletion doc/man/sr/mc.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ termcap/terminfo. Корисно је само на ХП\-овим термин
.B %pkglibexecdir%/mc.sh
(за кориснике љуски bash и zsh) или
.B %pkglibexecdir%/mc.csh
(за кориснике љуске tcsh), тим редом, да бисте задали
(за кориснике љуске tcsh) или
.B %pkglibexecdir%/mc.fish
(за кориснике љуске fish), тим редом, да бисте задали
.B mc
као надимак за одговарајући спис љуске.
.TP
Expand Down
Loading