TIL: Bash has a nice hook to intercept the exact line the user entered.
Ivan Velichko
Visit on X@iximiuz76K followers
13,694 views
TIL: Bash has a nice hook to intercept the exact line the user entered.
The idea is rather simple. Bash uses readline() to get the final user input, and attaching a u(ret)probe to it lets you see the whole string.
Immediately taught ShellGym this trick:
3 Comments
Comments from the original post on X (Twitter)

@buswe_com
bpftrace -e 'uretprobe:/bin/bash:readline { printf("%s\n", str(retval)); }' streams every line live, no bashrc changes.

@NickHirras
Classic bpftrace bashreadline trick. Gotcha: Ubuntu links readline statically into bash, so you probe /bin/bash:readline, not On distros that link it dynamically the probe target flips.

@DadiArna
6fðð688hh Gy
