Equivalent for typeset -l and typeset -u in LINUX bash?

Justin picture Justin · Jun 18, 2012 · Viewed 10.6k times · Source

I'm in the process of porting over a script from HP-UX to LINUX. When I try to source the script, bash complains that

bash: typeset: -u: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...

typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
./install_profile: line 237: typeset: -l: invalid option

From what I can see, typeset is used to assign a value to a variable, although I don't quite understand what typeset -u and typeset -l do specifically that's different from a general assignment such as foo="bar".

I was wondering if there was some equivalent way to express typeset -u and typeset -l for LINUX bash since it does not appear to be compatible with bash.

Altneratively, I was wondering if it would be possible to get the typeset commands recognized as ksh commands, since it appears that typeset is from ksh.

Thanks.

Answer

chepner picture chepner · Jun 18, 2012

What versions of bash are you porting from/to? typeset -l makes the variable such that any assignment to it converts upper case to lower case; typeset -u converts lower to upper. I suspect those options were added to bash sometime around version 4.