On 07/07/2022 12:52 AM, Jon LaBadie wrote: > On Wed, Jul 06, 2022 at 09:41:14PM -0400, H wrote: >> I have run into a bash variable string problem that I think I have nailed down to the variable string containing a tilde (~). Not sure if my conclusion is correct and could use some help. >> >> To make a long(er) story short, an associative array variable was created: >> >> p[work_path]="~/projects/test/" >> >> and referenced in the following format in the shell script: >> >> "${p[work_path]}" > > Is there a reason you desire "delayed" evaluation of the tilde? > > If no, then evaluate the tilde in the above assignment by not > quoting it. > > If yes, then where tilde evaluation IS wanted, you will likely > need to do a second round of shell evaluation of the command > line by using the keyword "eval". > > $ x="~/foo" > $ y=~"/foo" # y contains the tilde evaluated version > > $ echo "$x $y" > ~/foo /home/jon/foo > > $ echo $x $y # quotes don't matter here > ~/foo /home/jon/foo > > $ eval echo "$x $y" > /home/jon/foo /home/jon/foo > > > Use of eval could introduce other unexpected/unwanted > evaluations and is discouraged unless required. > Thank you, I read up on bash expansion of tilde and realized substituting $HOME for ~ would be the best and would avoid any other unforeseen complications. Once I had done that the script worked. _______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx https://lists.centos.org/mailman/listinfo/centos