help-bash
[Top][All Lists]
Advanced

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

Execute function on --exec option


From: tolugboji
Subject: Execute function on --exec option
Date: Thu, 07 Oct 2021 18:00:36 +0000

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Thursday, October 7th, 2021 at 3:41 PM, Alex fxmbsw7 Ratchev 
<fxmbsw7@gmail.com> wrote:

> exec function only if --exec is given to the upper script ?
>
> check for that and do so, .. like u checked -v and such u can otherwhere
>
> check for --exec
>
> . ?

I have seen some using Bash Parameter Expansion, to check if a variable is set 
or null, or set a default.
Not quite sure whether Bash Parameter Expansion is a good idea and some 
expressions are quite hard to
decipher.

> On Thu, Oct 7, 2021, 17:07 tolugboji via help-bash@gnu.org wrote:
>
> > I have the following code and want to be able to execute the function only
> >
> > when the option `--exec`
> >
> > is used. How can I achieve that?
> >
> > environ-texinfo ()
> >
> > {
> >
> > case $1 in
> >
> > ("-V"|"--version")
> >
> > local -r date="V01 2021 Jul 21 Wk27"
> >
> > printf "$date\n"
> >
> > return
> >
> > ;;
> >
> > ("-h"|"--help")
> >
> > printf "Set environment for texinfo.\n"
> >
> > printf "Invoke texinfo using a unix-like command terminal.\n"
> >
> > printf "Command: \`texinfo &\\'" return ;; (*) printf "Invoke 
> > \\`environ-texinfo -h\` for detail.\n"
> >
> > ;;
> >
> > esac
> >
> > export TEXINFO_PATH=/usr/local/bin
> >
> > export PATH=$PATH:$TEXINFO_PATH
> >
> > }
> >
> > export -f linge-environ-texinfo



reply via email to

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