|
From: | Dennis Williamson |
Subject: | Re: [Help-bash] How to extrapolate bash string? |
Date: | Thu, 12 Sep 2013 13:55:07 -0500 |
Use $HOME or getent instead of ~
Hi,
I use the following code to extrapolate bash string. I'm wondering if
this might not be robust in some corner cases. Does anybody have any
better solution? Thanks.
~/linux/bashrc/src/extrapbashstr/main$ cat main.sh
#!/usr/bin/env bash
function extrapbashstr {
echo $(eval echo "$1")
}
extrapbashstr '~'
x=blah
extrapbashstr '/tmp/ $x'
~/linux/bashrc/src/extrapbashstr/main$ ./main.sh
/home/<username>
/tmp/ blah
--
Regards,
Peng
[Prev in Thread] | Current Thread | [Next in Thread] |