On 2020-08-31 at 04:41:56, Daniel Shahaf wrote: > I guess it should be in the zprofile file, guarded by a [[ -o interactive ]] > check.
>From the comment in /etc/zsh/zshrc: # This file is sourced only for interactive shells. It # should contain commands to set up aliases, functions, # options, key bindings, etc. I thought it was a better fit, given that /etc/zsh/zprofile claims it's only for login shells: # This file is sourced only for login shells (i.e. shells # invoked with "-" as the first character of argv[0], and # shells invoked with the -l flag.) Or maybe I got that wrong? > > However, I don't see a way for packages to do this. So I guess there would > > be two ways to make this possible: > > > > 1. The main /etc/zsh/zshrc script could source all .sh files in a new > > /etc/zsh/zshrc.d/ directory. > > 2. The /etc/zsh/zshrc that ships in Debian could include the above. > > > > Are either of these something you'd be willing to consider? > > I don't have an opinion one way or the other. > > I do note that optionĀ #2 would cause a stat(2) call during shell startup > for everyone who _doesn't_ use safe-rm. Would that be a problem? > (E.g., slower shell startup) Good point about the extra stat. I honestly don't know whether that kind of impact can even be reliably measured, but you're right that it would be unnecessary for non-users of safe-rm. > Probably not what you had in mind, but my first instinct here is to look > for a shell-independent solution. For example: Indeed, that's an excellent approach and is in fact where I started. > 3. Get the OS to add /usr/share/safe-rm/bin to $PATH before the user's > shell is executed in the first place. (On FreeBSD that'd be > login.conf(5), but I don't know what the Linux equivalent is.) That appears to be in /etc/login.defs, but without any way for a package to configure. There was a nice way to do that in the past given that /usr/bin was in front of /bin in the path, but that became impossible once /usr/bin and /bin got merged: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=759410 > 4. Use dpkg-divert(8) to replace /bin/rm with a wrapper that calls > either safe-rm or the diverted rm binary, depending on whether it's > interactive or not. That was my first attempt and it turned out to be extremely risky and hard to get right: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=489690 > If you don't already know them, see RM_STAR_SILENT and RM_STAR_WAIT in > zshoptions(1). Oh, that's very cool! A very good complement to safe-rm in fact since that's not something safe-rm can do anything about since the shell expands these globs before passing the paths to the rm command. > P.S. Compare #489646, about providing a directory for packages to drop > completion files into. (That didn't involve reimplementing > run-parts(1), though; it was just a matter of adding a directory to > a list of directories.) Yes, having a /usr/share/zsh/vendor-config/ or similar would be very good. It certainly doesn't have to live in /etc/. Francois -- https://fmarier.org/