help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: redirection back to tty problem


From: Chris Elvidge
Subject: Re: redirection back to tty problem
Date: Sun, 27 Feb 2022 13:43:18 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Lightning/5.4

On 27/02/2022 12:14, Alex fxmbsw7 Ratchev wrote:
well i forwarded your text to him
in the end ppl in #bash helped me get it up, the my script

cat cmdhelp
#!/usr/bin/env -S bash

# for to be sourced in .bashrc or such

i=${SRANDOM:-$RANDOM}

t=/tmp/.$i o2=$t.2

trap '
if [[ $BASH_COMMAND == *--help* ]] ; then
  exec {fd1}>&1 {fd2}>&2 >"$o2" 2>&1
  cmd=$BASH_COMMAND
  printf %s\\n\\n "$cmd"
fi' debug

PROMPT_COMMAND='
if [[ $cmd ]] ; then
  exec >&$fd1 2>&$fd2
  vim "$o2"
  exec {fd1}>&- {fd2}>&-
  cmd=
fi
'$PROMPT_COMMAND


Shouldn't you allow for '-h' as well as '--help'?

--
Chris Elvidge
England




reply via email to

[Prev in Thread] Current Thread [Next in Thread]