Are there valid names for functions in Bash?

Are there valid names for functions in Bash?

There’s not security issue here as the functions you (the script author) define are the ones you invoke. Where there may be security issues is when the parsing is affected by the environment, for instance with shells where the valid names for functions is affected by the locale.

How to use a regex in a shell script?

Note, however, that the caveat re using flavor-specific regex constructs such as \\d equally applies : While =~ supports EREs ( extended regular expressions), it also supports the host platform’s specific extension – it’s a rare case of Bash’s behavior being platform-dependent.

How do you use functions in bash scripting?

Divide and Conquer. Functions in Bash Scripting are a great way to reuse code. In this section of our Bash scripting tutorial you’ll learn how they work and what you can do with them. Think of a function as a small script within a script. It’s a small chunk of code which you may call multiple times within your script.

How are function names and arguments used in shell?

A simple command in shell is a list of arguments, and the first argument is used to derive the command to execute. So, it’s just logical that those arguments and function names share the same possible values and in zsh arguments to builtins and functions can be any byte sequence.

What are the identifiers and blanks in Bash?

A blank is a tab or a space. An identifier is a sequence of letters, digits, or underscores starting with a letter or underscore. Identifiers are used as components of variable names. A vname is a sequence of one or more identifiers separated by a . and optionally preceded by a .. Vnames are used as function and variable names.

Can a function name be multiple bytes in Bash?

Since POSIX documentation allow it as an extension, there’s nothing prevent implementation from that behavior. show that bash, zsh, yash, ksh93 (which ksh linked to in my system), pdksh and its derivation allow multi-bytes characters as function name.

Can you use extended Unicode characters in Bash?

Using extended Unicode characters is (no-doubt) useful for many users. But bash, mksh, lksh, and zsh seem to allow it. I am aware that POSIX valid function names use this definition of Names.