help-bash
[Top][All Lists]
Advanced

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

[Help-bash] What are the regex spec for function names?


From: Peng Yu
Subject: [Help-bash] What are the regex spec for function names?
Date: Sat, 8 Dec 2018 06:31:44 -0600

Hi,

Bash allows many special characters in function names (commented ones
are not allowed to be defined, or cannot be referred once defined). Is
there a regex that specific what are valid function names in Bash?
Thanks.

$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
function ! { declare -p FUNCNAME; }; !
#function # { declare -p FUNCNAME; }
#function $ { declare -p FUNCNAME; }
#function % { declare -p FUNCNAME; }
function a% { declare -p FUNCNAME; }; a%
#function & { declare -p FUNCNAME; }
#function * { declare -p FUNCNAME; }; *
function + { declare -p FUNCNAME; }; +
function - { declare -p FUNCNAME; }; -
function , { declare -p FUNCNAME; }; ,
function / { declare -p FUNCNAME; }; /
function ? { declare -p FUNCNAME; }; ?
# function | { declare -p FUNCNAME; }
function . { declare -p FUNCNAME; }; .
function @ { declare -p FUNCNAME; }; @
#function ~ { declare -p FUNCNAME; }; ~
$ ./main.sh
function ! { declare -p FUNCNAME; }; !
#function # { declare -p FUNCNAME; }
#function $ { declare -p FUNCNAME; }
#function % { declare -p FUNCNAME; }
function a% { declare -p FUNCNAME; }; a%
declare -a FUNCNAME=([0]="a%" [1]="main")
#function & { declare -p FUNCNAME; }
#function * { declare -p FUNCNAME; }; *
function + { declare -p FUNCNAME; }; +
declare -a FUNCNAME=([0]="+" [1]="main")
function - { declare -p FUNCNAME; }; -
declare -a FUNCNAME=([0]="-" [1]="main")
function , { declare -p FUNCNAME; }; ,
declare -a FUNCNAME=([0]="," [1]="main")
function / { declare -p FUNCNAME; }; /
declare -a FUNCNAME=([0]="/" [1]="main")
function ? { declare -p FUNCNAME; }; ?
declare -a FUNCNAME=([0]="?" [1]="main")
# function | { declare -p FUNCNAME; }
function . { declare -p FUNCNAME; }; .
declare -a FUNCNAME=([0]="." [1]="main")
function @ { declare -p FUNCNAME; }; @
declare -a FUNCNAME=([0]="@" [1]="main")
#function ~ { declare -p FUNCNAME; }; ~


-- 
Regards,
Peng



reply via email to

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