Subject: Re: bug#20679: A bug of pwd

From: Bernhard Voelker <[email-masked]>
Date: Thu, 28 May 2015 09:32:21 +0200

tag 20679 notabug
close 20679
stop

On 05/28/2015 06:08 AM, 徐兴旺 wrote:
> If the name of current diretory including blank, pwd return raw blank istead of escaping character, "\ ".
> When used with cp command, the directory name will be recognized two params.

If I understand correctly, then you have a script doing something like
the following:

   $ mkdir "a dir"
   $ cd "a dir"
   $ cp -v /dev/null $(pwd)
   cp: target ‘dir’ is not a directory

First of all, I want to mention that the invoked 'pwd' is a builtin
in most shells, which means you have to e.g. specify the path like
/bin/pwd to be sure to invoke the coreutils version of it.

Second, the output of pwd(1) is correct - i.e., there is no such
thing than escaping characters.  Instead, the caller has to care
about proper quoting:

   $ cp -v /dev/null "$(pwd)"
   ‘/dev/null’ -> ‘/tmp/a dir/null’

Therefore, I'm marking this as "not a bug" in our software.  But in case
of questions please don't hesitate to discuss this further by replying
to this bug.

Have a nice day,
Berny