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: Alex fxmbsw7 Ratchev
Subject: Re: redirection back to tty problem
Date: Sun, 27 Feb 2022 16:33:46 +0100

im not sure, the op asker said --help so i kept that
he was thankful for both codes

On Sun, Feb 27, 2022 at 2:43 PM Chris Elvidge <celvidge001@gmail.com> wrote:

> 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]