Bug: bind -u shell-backward-word does not unbind the binding

2020-02-27 Thread lockywolf
--text follows this line--
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Description:
It is possible to bind shell-backward-word, but not possible to unbind.

 Bash Version: 5.0
 Patch Level: 16
 Release Status: release

Repeat-By:
1) bind '"\e\C-b": shell-backward-word' # make binding
2) bind -P # to check that the binding appeared
3) bind -u shell-backward-word # to unbind the binding
4) bind -P # to check that unbinding didn't work

Fix:
I don't know how to fix the problem.
 Configuration Information [Automatically generated, do not change]:
 Compilation CFLAGS: -O2 -fPIC -Wno-parentheses -Wno-format-security
 uname output: Linux delllaptop.lockywolf.net 5.4.21 #1 SMP Wed Feb 19 19:09:47 
CST 2020 x86_64 Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz GenuineIntel GNU/Linux
 Machine Type: x86_64-slackware-linux-gnu

Date: Thu, 27 Feb 2020 21:39:02 +0800
Message-ID: <87k148jgjt@delllaptop.lockywolf.net>



Feature request: process title with exec -a "" for oneself

2024-08-31 Thread Lockywolf
Dear Bash developers,

May I ask for a small feature to be added to bash?

At the moment exec changes IO redirections for the newly started
processes, but if there is no command for exec'ing, it changes those
redirections for the bash process itself.

The exec -a, however, allows setting the current process title (argv0)
only for the newly exec'ed processes, and "exec -a whatever" (without a
command) does nothing.

However it seems to be possible (albeit in a series of 8 syscalls) to
change the _current_ process' cmdline and argv0:

1. https://unix.stackexchange.com/a/438007/541470
2. https://github.com/jdebp/nosh/blob/master/source/setprocargv.cpp
3. https://github.com/jdebp/nosh/blob/master/source/setprocenvv.cpp

Would it be possible to add this behaviour to the "exec" bash builtin?

Thank you and sorry if this is too much to ask.

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)



Re: Feature request: process title with exec -a "" for oneself

2024-09-05 Thread Lockywolf

Chet Ramey  writes:

> So I assume that you want to change the kernel's idea of the process
> arguments as seen and displayed by `ps'. If so, I'm not really interested
> in adding that as a feature. It doesn't seem to add anything for shell
> users.

Well, I am a shell user :).

I would really love to have such a feature because I have two use-cases
for it.

1. I would use it as a super minimalist progress indicator for one-shot
scrips written with little consideration.

For example, I sometimes find myself writing something like:
`while true; do try_something_slow && exit 0 ; sleep 1 ; done &`

With a setproctitle I would write something like:

`I=0 ; while true; do try_something_slow && exit 0 ; I=$((I + 1)) ;
setproctitle "trier_$I-times" sleep 1 ; done &`

And this leaves no lingering files, does not require finding a PID to
look at `/proc/$pid/environ`, et cetera. I can just query the progress
using `ps`.

2. I would use it to distinguish subshells from the current script in
`ps`.

By default a subshell has the same name as the parent shell.
So when I run `ps/pgrep`, I often get processes with the same name, and
I'd have to parse the output of `pstree` to find out which is which.
And running exec -a "${BASH_ARGV0}_child" while true ; do sleep 1 ; done &
is not a valid syntax.

I think this would greatly simplify debugging shell scripts, but maybe
it's just me.

>I think this is appropriate for a loadable builtin. This one is Linux-
>specific.

I am not experienced enough to have an opinion on whether a loadable
built-in is better than a feature of "exec".

-- 
Your sincerely,
Vladimir Nikishkin (MiEr, lockywolf)
(Laptop)


signature.asc
Description: PGP signature