#300470 zsh: trap mechanism on command-line length limitation with zargs-based fallback

Package:
zsh
Source:
zsh
Description:
shell with lots of features
Submitter:
Vincent Lefevre
Date:
2012-12-20 23:36:09 UTC
Severity:
wishlist
#300470#5
Date:
2005-03-19 23:17:05 UTC
From:
To:
Note: this is a linux-only wishlist; I hope this wouldn't be a problem
for upstream.

It is well-known that the Linux kernel has a limitation on the length
of the command line. A solution is to use xargs or zargs (probably
better with zsh), but when typing interactive commands in particular,
this is annoying.

So, what I wish, is:
  * a configurable command-based trap mechanism when the command line
    is too long;
  * default fallbacks distributed with the zsh package.

Here's an example: I type "rm **/*.foo". If the command line is not too
long, the rm command is executed as expected. Otherwise, an alternate
rm command (something like a builtin) is executed, using zargs. This
alternate command should be able to cope with the various rm options,
special filenames (e.g. starting with a '-') and error handling to hide
the unwanted side effects of the rm wrapper.

Ditto for the other common commands (mv, cp, etc.).

#300470#8
Date:
2005-03-20 04:48:03 UTC
From:
To:
Any thoughts on this idea?
----- Forwarded message from Vincent Lefevre <vincent@vinc17.org> ----- Note: this is a linux-only wishlist; I hope this wouldn't be a problem for upstream. It is well-known that the Linux kernel has a limitation on the length of the command line. A solution is to use xargs or zargs (probably better with zsh), but when typing interactive commands in particular, this is annoying. So, what I wish, is: * a configurable command-based trap mechanism when the command line is too long; * default fallbacks distributed with the zsh package. Here's an example: I type "rm **/*.foo". If the command line is not too long, the rm command is executed as expected. Otherwise, an alternate rm command (something like a builtin) is executed, using zargs. This alternate command should be able to cope with the various rm options, special filenames (e.g. starting with a '-') and error handling to hide the unwanted side effects of the rm wrapper. Ditto for the other common commands (mv, cp, etc.).
----- End forwarded message -----
#300470#9
Date:
2005-03-20 19:41:31 UTC
From:
To:
I think it's unnecessary.  For interactive use, you can get most of the
same effect by using a "preexec" function (see e.g. zsh-users/4140, or
zsh-users/6463 which extends it) or other function wrappers.  The only
hard part is finding out what the argument length limit *is*, because
it's not available from e.g. the rlimits module.

Also, we've had discussions of exec "traps" in the past, and avoided
them because they're dangerous -- it becomes too easy to put the shell
in a state where it can't do anything at all.

Other comments:

"An alternate rm command" -- and mv, ln, etc. -- is already available in
the zsh/files module.  It "copes with all the various rm options" and is
not bound by the argument length limitations.  It actually is a builtin,
rather than just "something like" one, and it's distributed with the zsh
package.  ("cp" is currently missing, IIRC because it was decided that
a builtin couldn't do it any more efficiently than was already possible
with redirections, but it could be added.)