[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Allowing dash in variable and function names
From: |
konsolebox |
Subject: |
Re: Allowing dash in variable and function names |
Date: |
Tue, 6 Apr 2021 13:22:25 +0800 |
On Tue, Apr 6, 2021 at 1:08 PM Lawrence Velázquez <vq@larryv.me> wrote:
> The "function" keyword is not necessary.
>
> bash-5.1$ this-works-fine() { echo hello world; }
> bash-5.1$ declare -f this-works-fine
> this-works-fine ()
> {
> echo hello world
> }
> bash-5.1$ this-works-fine
> hello world
I always forget that as I no longer use the func() { ... } format in bash.
This won't work though.
shopt -s extlob
is_a_number?() { [[ $1 == +([[:digit:]]) ]]; }
But this will.
function is_a_number? { [[ $1 == +([[:digit:]]) ]]; }
--
konsolebox