Patchwork [1,of,5,STABLE] dockerdeb: elimate 'cd' in export command

login
register
mail settings
Submitter Sean Farley
Date April 17, 2016, 7:12 a.m.
Message ID <13497f113084b34a3923.1460877137@laptop.local>
Download mbox | patch
Permalink /patch/14701/
State Superseded
Headers show

Comments

Sean Farley - April 17, 2016, 7:12 a.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1460763964 25200
#      Fri Apr 15 16:46:04 2016 -0700
# Branch stable
# Node ID 13497f113084b34a392332070581433e9384f6a2
# Parent  e442b628bfe6485d57ab4f10f941b89e96f04b05
# EXP-Topic ppa
dockerdeb: elimate 'cd' in export command

This had the unfortunate side effect of causing the environment to have a
newline due to the fact that some 'cd' outputs the result of the directory
change.
Anton Shestakov - April 17, 2016, 9:21 a.m.
17.04.2016, 15:12, "Sean Farley" <sean@farley.io>:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1460763964 25200
> # Fri Apr 15 16:46:04 2016 -0700
> # Branch stable
> # Node ID 13497f113084b34a392332070581433e9384f6a2
> # Parent e442b628bfe6485d57ab4f10f941b89e96f04b05
> # EXP-Topic ppa
> dockerdeb: elimate 'cd' in export command
>
> This had the unfortunate side effect of causing the environment to have a
> newline due to the fact that some 'cd' outputs the result of the directory
> change.
>
> diff --git a/contrib/dockerdeb b/contrib/dockerdeb
> --- a/contrib/dockerdeb
> +++ b/contrib/dockerdeb
> @@ -2,11 +2,11 @@
>
>  . $(dirname $0)/dockerlib.sh
>  . $(dirname $0)/packagelib.sh
>
>  BUILDDIR=$(dirname $0)
> -export ROOTDIR=$(cd $BUILDDIR/..; pwd)
> +export ROOTDIR=$(pwd $BUILDDIR/..)

Um, what?

$ BUILDDIR=/var/tmp/foo
$ echo $(cd $BUILDDIR/..; pwd)
/var/tmp
$ echo $(pwd $BUILDDIR/..)
/home/a

This is on Debian.
Anton Shestakov - April 17, 2016, 9:52 a.m.
17.04.2016, 17:30, "Anton Shestakov" <engored@ya.ru>:
> 17.04.2016, 15:12, "Sean Farley" <sean@farley.io>:
>>  # HG changeset patch
>>  # User Sean Farley <sean@farley.io>
>>  # Date 1460763964 25200
>>  # Fri Apr 15 16:46:04 2016 -0700
>>  # Branch stable
>>  # Node ID 13497f113084b34a392332070581433e9384f6a2
>>  # Parent e442b628bfe6485d57ab4f10f941b89e96f04b05
>>  # EXP-Topic ppa
>>  dockerdeb: elimate 'cd' in export command
>>
>>  This had the unfortunate side effect of causing the environment to have a
>>  newline due to the fact that some 'cd' outputs the result of the directory
>>  change.
>>
>>  diff --git a/contrib/dockerdeb b/contrib/dockerdeb
>>  --- a/contrib/dockerdeb
>>  +++ b/contrib/dockerdeb
>>  @@ -2,11 +2,11 @@
>>
>>   . $(dirname $0)/dockerlib.sh
>>   . $(dirname $0)/packagelib.sh
>>
>>   BUILDDIR=$(dirname $0)
>>  -export ROOTDIR=$(cd $BUILDDIR/..; pwd)
>>  +export ROOTDIR=$(pwd $BUILDDIR/..)
>
> Um, what?
>
> $ BUILDDIR=/var/tmp/foo
> $ echo $(cd $BUILDDIR/..; pwd)
> /var/tmp
> $ echo $(pwd $BUILDDIR/..)
> /home/a
>
> This is on Debian.

In other words, pwd the built-in bash (also dash) command ignores all arguments. And here's what GNU pwd does:
$ /bin/pwd --version
pwd (GNU coreutils) 8.25
[...]
$ /bin/pwd /var/tmp
/bin/pwd: ignoring non-option arguments
/home/a
Sean Farley - April 17, 2016, 5:26 p.m.
Anton Shestakov <engored@ya.ru> writes:

> 17.04.2016, 17:30, "Anton Shestakov" <engored@ya.ru>:
>> 17.04.2016, 15:12, "Sean Farley" <sean@farley.io>:
>>> # HG changeset patch
>>> # User Sean Farley <sean@farley.io>
>>> # Date 1460763964 25200
>>> # Fri Apr 15 16:46:04 2016 -0700
>>> # Branch stable
>>> # Node ID 13497f113084b34a392332070581433e9384f6a2
>>> # Parent e442b628bfe6485d57ab4f10f941b89e96f04b05
>>> # EXP-Topic ppa
>>> dockerdeb: elimate 'cd' in export command
>>>
>>> This had the unfortunate side effect of causing the environment to have a
>>> newline due to the fact that some 'cd' outputs the result of the directory
>>> change.
>>>
>>> diff --git a/contrib/dockerdeb b/contrib/dockerdeb
>>> --- a/contrib/dockerdeb
>>> +++ b/contrib/dockerdeb
>>> @@ -2,11 +2,11 @@
>>>
>>> . $(dirname $0)/dockerlib.sh
>>> . $(dirname $0)/packagelib.sh
>>>
>>> BUILDDIR=$(dirname $0)
>>> -export ROOTDIR=$(cd $BUILDDIR/..; pwd)
>>> +export ROOTDIR=$(pwd $BUILDDIR/..)
>>
>> Um, what?
>>
>> $ BUILDDIR=/var/tmp/foo
>> $ echo $(cd $BUILDDIR/..; pwd)
>> /var/tmp
>> $ echo $(pwd $BUILDDIR/..)
>> /home/a
>>
>> This is on Debian.
>
> In other words, pwd the built-in bash (also dash) command ignores all arguments. And here's what GNU pwd does:
> $ /bin/pwd --version
> pwd (GNU coreutils) 8.25
> [...]
> $ /bin/pwd /var/tmp
> /bin/pwd: ignoring non-option arguments
> /home/a

Thanks, I'll rework this.
Pierre-Yves David - April 17, 2016, 7:35 p.m.
On 04/17/2016 10:26 AM, Sean Farley wrote:
> Anton Shestakov <engored@ya.ru> writes:
>
>> 17.04.2016, 17:30, "Anton Shestakov" <engored@ya.ru>:
>>> 17.04.2016, 15:12, "Sean Farley" <sean@farley.io>:
>>>> # HG changeset patch
>>>> # User Sean Farley <sean@farley.io>
>>>> # Date 1460763964 25200
>>>> # Fri Apr 15 16:46:04 2016 -0700
>>>> # Branch stable
>>>> # Node ID 13497f113084b34a392332070581433e9384f6a2
>>>> # Parent e442b628bfe6485d57ab4f10f941b89e96f04b05
>>>> # EXP-Topic ppa
>>>> dockerdeb: elimate 'cd' in export command
>>>>
>>>> This had the unfortunate side effect of causing the environment to have a
>>>> newline due to the fact that some 'cd' outputs the result of the directory
>>>> change.

The case I know where cd output the directory change is with bash when 
you are using the CDPATH feature.

>>>>
>>>> diff --git a/contrib/dockerdeb b/contrib/dockerdeb
>>>> --- a/contrib/dockerdeb
>>>> +++ b/contrib/dockerdeb
>>>> @@ -2,11 +2,11 @@
>>>>
>>>> . $(dirname $0)/dockerlib.sh
>>>> . $(dirname $0)/packagelib.sh
>>>>
>>>> BUILDDIR=$(dirname $0)
>>>> -export ROOTDIR=$(cd $BUILDDIR/..; pwd)
>>>> +export ROOTDIR=$(pwd $BUILDDIR/..)
>>> Um, what?
>>>
>>> $ BUILDDIR=/var/tmp/foo
>>> $ echo $(cd $BUILDDIR/..; pwd)
>>> /var/tmp
>>> $ echo $(pwd $BUILDDIR/..)
>>> /home/a
>>>
>>> This is on Debian.
>> In other words, pwd the built-in bash (also dash) command ignores all arguments. And here's what GNU pwd does:
>> $ /bin/pwd --version
>> pwd (GNU coreutils) 8.25
>> [...]
>> $ /bin/pwd /var/tmp
>> /bin/pwd: ignoring non-option arguments
>> /home/a
> Thanks, I'll rework this.
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Sean Farley - April 17, 2016, 7:55 p.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> On 04/17/2016 10:26 AM, Sean Farley wrote:
>> Anton Shestakov <engored@ya.ru> writes:
>>
>>> 17.04.2016, 17:30, "Anton Shestakov" <engored@ya.ru>:
>>>> 17.04.2016, 15:12, "Sean Farley" <sean@farley.io>:
>>>>> # HG changeset patch
>>>>> # User Sean Farley <sean@farley.io>
>>>>> # Date 1460763964 25200
>>>>> # Fri Apr 15 16:46:04 2016 -0700
>>>>> # Branch stable
>>>>> # Node ID 13497f113084b34a392332070581433e9384f6a2
>>>>> # Parent e442b628bfe6485d57ab4f10f941b89e96f04b05
>>>>> # EXP-Topic ppa
>>>>> dockerdeb: elimate 'cd' in export command
>>>>>
>>>>> This had the unfortunate side effect of causing the environment to have a
>>>>> newline due to the fact that some 'cd' outputs the result of the directory
>>>>> change.
>
> The case I know where cd output the directory change is with bash when 
> you are using the CDPATH feature.

Yeah, that's probably what caused this. I sent a V2 which should be much
safer overall (feel free to add more comments to the commit message).

Patch

diff --git a/contrib/dockerdeb b/contrib/dockerdeb
--- a/contrib/dockerdeb
+++ b/contrib/dockerdeb
@@ -2,11 +2,11 @@ 
 
 . $(dirname $0)/dockerlib.sh
 . $(dirname $0)/packagelib.sh
 
 BUILDDIR=$(dirname $0)
-export ROOTDIR=$(cd $BUILDDIR/..; pwd)
+export ROOTDIR=$(pwd $BUILDDIR/..)
 
 checkdocker
 
 DISTID="$1"
 CODENAME="$2"