[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] No tilde expansion in [[..]] when reading input with rea
Re: [Help-bash] No tilde expansion in [[..]] when reading input with read
Mon, 25 Feb 2013 22:35:01 +0800
On 2013-02-25 08:37, Greg Wooledge wrote:
> Ironically, stripping all characters except alphanumeric, underscore,
> and maybe a few other well-chosen bits of punctuation, and then using
> eval, may be the safest and most portable way to go.
> IFS= read -r raw_username
> if [[ $username = "$raw_username" ]]; then
> eval "home=~$username"
> echo "home=<$home>"
> echo "Nice try, but no."
Aren't some of the excluded characters legal on some Unices, though? If I recall
correctly, some are constrained by NAME_REGEX rather than actual limitations in
storing user metadata. Perhaps I remember wrongly.