The following works:
$ zip -rj /the/absolute/path/tmp{.zip,}
It produced a file called tmp.zip, saving me the trouble to repeat the folder name as the name of the zip archive.
In my rifle.conf (ranger specific configuration file) I have:
!mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = zip -rj "$@"{.zip,}
The "$@" translates to the path. This works fine, I make use of this a lot.
But when I try it, the error I get is:
zip error: Nothing to do! (/the/absolute/path/tmp{.zip,})
This has worked fine for me, too. It only stopped working after upgrading my OS and with it ranger. So there is likely something I am missing here.
$ ranger --version
ranger version: ranger 1.9.3
Python version: 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
Locale: en_US.UTF-8
$ cat /etc/upstream-release/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu Focal Fossa"
The brace expansion which turns
foo{bar,cbs}baz
intofoobarbaz foocbsbaz
is done bybash
when interpreting a command line. So the most probable explanation is that since the upgrade,ranger
doesn't usebash
for the execution of the command anymore.Regrettably,
ranger
does not seem to document which shell it uses to interpret the commands inrifle.conf
or whether that can be influenced. You may try to set theSHELL
environment variable to/bin/bash
in various places to see if it helps. If all else fails, write a wrapper shell script starting with#!/bin/bash
around your command.What was actually going on here is that ranger does a thing where if you execute files via shortcuts that things are executed as configured. In the case for shell this meant to do a call to "sh".
In previous versions of Linux Mint sh was just symlinked to bash, so the shortcut worked as "bash" in practice, even if if under the hood it was defined as sh.
But in the newer version, sh is no longer symlinked to bash, so you get a different shell and bash scripts throw weird errors, because they aren't executed as bash by the shortcut.
The fix is then to just update the config from sh to bash in the shortcut configuration (rifle.conf).
I solved it by not using zip, but apack instead.
This works: