0

I want a $(thing/command/variable) like PROMPT_COMMAND, but for a nonintervention shell script that runs a command every line $(in the same Bash instance). For example,

Normal

echo hel
echo hel
echo hel
echo hel

After thing

thingcom "sleep 1" # Note this would act as if this was the case

echo hel
sleep 1
echo hel
sleep 1
echo hel
sleep 1
echo hel
sleep 1
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
lnee_94
  • 25
  • 6
  • See in particular the answer https://stackoverflow.com/a/45123073/14122 on the linked duplicate, suggesting use of a DEBUG trap. – Charles Duffy Oct 10 '21 at 17:59
  • non interactave shell script – lnee_94 Oct 10 '21 at 18:02
  • @lnee_94, if the linked duplicate doesn't address your question, please edit to describe why and how it fails to do so. – Charles Duffy Oct 10 '21 at 18:04
  • (DEBUG traps _do_ have caveats, but we have other Q&A entries -- such as https://stackoverflow.com/questions/51557238/why-is-the-debug-trap-executed-more-times-than-expected -- describing them). – Charles Duffy Oct 10 '21 at 18:07

0 Answers0