home directory in path fail in BASH

Bug #424083 reported by joewski
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: bash

This complex command works
cp -v "install "* ~/.gnome2/nautilus-scripts

Now if you do this it works
 mkdir ~/.gnome2/nautilus-scripts/testdirectory

if you try this it fails
mkdir "~/.gnome2/nautilus-scripts/test directory"
you get this message
mkdir: cannot create directory `~/.gnome2/nautilus-scripts/test directory': No such file or directory

basically the ~ representing the home directory does not get recognized correctly by the command interpreter.

but if you do this it works
 mkdir "/home/joseph/.gnome2/nautilus-scripts/test directory"

where /home/joseph is your own home directory.

doing this doesn't work either in case you thought my syntax is wrong.
mkdir ~"/.gnome2/nautilus-scripts/test directory"
mkdir: cannot create directory `~/.gnome2/nautilus-scripts/test directory': No such file or directory

I discovered this bug when I started working on nautilus-scripts which are very handy in improving the user interface. While there are work arounds it make the scripting more difficult to program.

This bug isn't only isolated to mkdir command but other commands like cp.

The version of bash loaded on the machine is
bash --version
GNU bash, version 3.2.48(1)-release (i486-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.

ProblemType: Bug
Architecture: i386
DistroRelease: Ubuntu 9.04
ExecutablePath: /usr/bin/yelp
Package: yelp 2.25.1-0ubuntu5
ProcEnviron:
 LANG=en_AU.UTF-8
 SHELL=/bin/bash
SourcePackage: yelp
Uname: Linux 2.6.28-15-generic i686

Tags: bash-bug i386
Revision history for this message
joewski (joewski) wrote :
description: updated
Revision history for this message
joewski (joewski) wrote :

A further note if you do this it works
mkdir $HOME"/.gnome2/nautilus-scripts/test directory"

This also works correctly
echo ~

As this does to

echo $HOME

Revision history for this message
joewski (joewski) wrote :

interestingly
echo "~"
results in this
~

while
echo "~"~
results in this
~~
which should be
~/home/joseph

while
echo ~ "~"`
/home/joseph ~~

while
echo ~"~"~
results in
~~~
which is inconcistent, should be
/home/joseph~/home/joseph

also
echo $HOME"
results in getting
>
which you have to ctrl-c to get the command line back

but if you do this
echo $HOME"~"
you get this
/home/joseph~

There is a lot of inconcistency here.

Revision history for this message
joewski (joewski) wrote :

sorry typo.

while
echo ~ "~"
should be
/home/joseph ~

Revision history for this message
Andrew McCarthy (andrewmccarthy) wrote :

Thanks for taking the time to report this. It's bash that is expanding the tilde and, as confusing as it may seem at first, the documentation is fairly specific about how and when it works (see "Tilde Expansion" in the man page). Changing it would probably break lots of things, so it's not likely to change now, sorry!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.