[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash don't interpret ~ path with multiple options.
From: |
Greg Wooledge |
Subject: |
Re: Bash don't interpret ~ path with multiple options. |
Date: |
Mon, 4 Jun 2018 08:33:12 -0400 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Sun, Jun 03, 2018 at 02:32:03PM -0400, Chet Ramey wrote:
> On 6/2/18 10:08 PM, Jungsub Shin wrote:
> > # mount -o remount,append=~/test_aufs/ro1=ro+wh ~/test_aufs/mount
> >
> > mount failed with ~/test_aufs/ro1 path isn't exist message.
> > So i try to debug with strace and i find out bash don't replace ~
> > path to absolute path.
> Tilde expansion happens at the beginning of a word or after the `='
> and every `:' on the rhs of an assignment statement. Bash extends this to
> words that satisfy the criteria for assignment statements but appear as
> arguments to a command (so things like `export DIR=~/foo' work). The
> `remount,append=...' word does not satisfy the requirements for an
> assignment statement, since the characters before the `=' don't make up
> a valid shell identifier, so the tilde doesn't get expanded.
When in doubt, use "$HOME" instead of ~ to ensure that the expansion
will occur.
mount -o remount,append="$HOME"/test_aufs/ro1=ro+wh ~/test_aufs/mount
If you had been attempting to use ~user instead of ~ then I would
have recommended a temporary variable:
dir=~user/testaufs/ro1
mount -o remount,append="$dir"/test_aufs/ro1=ro+wh ~user/test_aufs/mount