[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to define functions as one cmd without brackets
From: |
alex xmb ratchev |
Subject: |
Re: how to define functions as one cmd without brackets |
Date: |
Wed, 1 Mar 2023 22:47:30 +0100 |
On Wed, Mar 1, 2023, 10:43 PM Lawrence Velázquez <vq@larryv.me> wrote:
> On Wed, Mar 1, 2023, at 4:38 PM, alex xmb ratchev wrote:
> > .. just few days ago i think here was someone with such functions
> > f() cmd ;
> >
> > i tried that in the scp script , and in terminal , cant such
> >
> > i tried
> > smth() return 1 ;
> > and similiar less shell keyword ing
>
> That only works with compound commands.
>
> bash-5.2$ foo() if :; then echo hi; fi
> bash-5.2$ foo
> hi
>
> https://www.gnu.org/software/bash/manual/html_node/Shell-Functions.html
thank you for your kind fast answer
very good answer and link
root@localhost:~# f() ( printf $$\ $BASHPID\\n ) ; f
21938 23540
root@localhost:~# f() ( printf $$\ $BASHPID\\n ) ; f
21938 23542
root@localhost:~# f() ( printf $$\ $BASHPID\\n ) ; f
21938 23550
> --
> vq
>