Tilde-expansion in --long-options=

DoneSubmitted by Hartmut Goebel.
Details
7 participants
  • Bengt Richter
  • Danny Milosavljevic
  • Hartmut Goebel
  • Leo Famulari
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
  • zimoun
Owner
unassigned
Severity
normal
H
H
Hartmut Goebel wrote on 30 Apr 2020 10:15
--load-path does not honor ~
(name . bug-guix)(address . bug-guix@gnu.org)
9fc5fc35-10c6-dda3-1e11-36740e4510c4@crazy-compilers.com
Specifying the home directory using `~` (tilde) in `--load-path` doesnot add the proper path to
Does not work (not who "mypackage":
  guix package --load-path=~/path/tp/my/project -A mypackage
Using $HOME (which si resolve by the shell works:
  guix package --load-path=$HOME/path/tp/my/project -A mypackage

I would expect ~ and ~username to work, too.
Z
Z
zimoun wrote on 30 Apr 2020 17:31
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ0FYmFqx31C4Lhxix0zY6VQMr3GSFQZp6rN4BnbhZFbdQ@mail.gmail.com
Dear,
On Thu, 30 Apr 2020 at 10:17, Hartmut Goebel<h.goebel@crazy-compilers.com> wrote:
Toggle quote (8 lines)>> Specifying the home directory using `~` (tilde) in `--load-path` does> not add the proper path to>> Does not work (not who "mypackage":>> guix package --load-path=~/path/tp/my/project -A mypackage
It seems related to long vs short options, not to the expansion.

The short option works:
guix package -L ~/path/to/my/project -A mypackage
but not the long '--load-path='.

Toggle quote (2 lines)> I would expect ~ and ~username to work, too.
Same for '~username'.

Well, I think it is related to bug #40549, see [1].
[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=40549#14

All the best,simon
Z
Z
zimoun wrote on 30 Apr 2020 18:37
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ14xbfTtYCumU0S7-u3FwxQq0_wb_LPZourCPxL8A7aRA@mail.gmail.com
On Thu, 30 Apr 2020 at 17:31, zimoun <zimon.toutoune@gmail.com> wrote:
Toggle quote (15 lines)>> Dear,>> On Thu, 30 Apr 2020 at 10:17, Hartmut Goebel> <h.goebel@crazy-compilers.com> wrote:> >> > Specifying the home directory using `~` (tilde) in `--load-path` does> > not add the proper path to> >> > Does not work (not who "mypackage":> >> > guix package --load-path=~/path/tp/my/project -A mypackage>> It seems related to long vs short options, not to the expansion.
I am wrong. It is about the expansion. When using the short option,then the expansion is done by the shell.
Note that it should be the same for '--manifest=~/path/to/manifests/'.And all the '--long-options=~/path/to/something'.
Well, I do not find a function to expand tilde in Guile.

All the best,simon
H
H
Hartmut Goebel wrote on 30 Apr 2020 18:42
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 40977@debbugs.gnu.org)
52117c4b-3090-1ccf-5669-ff4c47935e19@crazy-compilers.com
Hi,
This is not related to #40549.
The short option "-L ~/…" works, since thin this case the shell resolves the tilde. Whereas for the long-option the shell does not revolve the tilde, since the tilde is in the middle of the argument. Yu can verify this yourself easily:
$ python -c 'import sys; print(sys.argv)' ~['-c', '/home/hartmut']$ python -c 'import sys; print(sys.argv)' -L ~['-c', '-L', '/home/hartmut']$ python -c 'import sys; print(sys.argv)' ---long=~['-c', '---long=~']

Proposed solution:
After processing options, guix need to "expanduser()" (as it is calledin Python) on all arguments which are paths.

-- RegardsHartmut Goebel
| Hartmut Goebel | h.goebel@crazy-compilers.com || www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 30 Apr 2020 18:50
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ0cEP3vJcT_me0J20Wm=b01PEEWYM1sGq5BL5+qVai=5A@mail.gmail.com
Dear Hartmut,
On Thu, 30 Apr 2020 at 18:42, Hartmut Goebel<h.goebel@crazy-compilers.com> wrote:
Toggle quote (2 lines)> The short option "-L ~/…" works, since thin this case the shell resolves the tilde. Whereas for the long-option the shell does not revolve the tilde, since the tilde is in the middle of the argument. Yu can verify this yourself easily:
Yes, you have right.

Toggle quote (5 lines)> Proposed solution:>> After processing options, guix need to "expanduser()" (as it is called> in Python) on all arguments which are paths.
I agree.I am not aware of such function in Guile.
All the best,simon
D
D
Danny Milosavljevic wrote on 30 Apr 2020 19:34
(name . zimoun)(address . zimon.toutoune@gmail.com)
20200430193439.0db54d2f@scratchpost.org
Toggle quote (3 lines)> After processing options, guix need to "expanduser()" (as it is called> in Python) on all arguments which are paths.
Please don't do it.
UNIX has its warts, and this is a well-known one (use ${HOME} instead).
If we did expanduser, I'm sure we'd be seeing bug reports about paths wherethere was a tilde in the actual file name, NOT as a expanduser mark.
UNIX tools do what they do, and this wart is here to stay in a lot of tools.Then at least make it consistent across all the tools UNIX has.
-----BEGIN PGP SIGNATURE-----
iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6rDC8ACgkQ5xo1VCwwuqXOzwf+L7U3vk0HQ8ehOS4D7fjZFXefXyDZuJJKjxbEz+2BSaoxUKGTSLPV6lHOm9cxMnlTbUPz8bGLa3Xp2p+7bYzAySWzEFbzjQmsKMizHVCu7FswaEHTChPlgzujLolyLA0GqteGGQDrlfFqpq6A1wz0x3gx0oktl+M5CfZQhqYFjwGwhhYreswtsiLlmNyHgO+XZiEGuAHlAycxvJQQhJrnJ4fpEVYufHUqJPIQow4+HOLAX9K9orb9ZlcYVKcTvBEYnPp7ejwhZ9fx/KQDZHaf9I24IFvsbsnYupjxaTtJNZXuP6Erm7wA11Yn4nB8GT2NC6RJAPx1jDy6l7DZdJoKNA===NZhE-----END PGP SIGNATURE-----

L
L
Leo Famulari wrote on 30 Apr 2020 19:53
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20200430175305.GA26916@jasmine.lan
On Thu, Apr 30, 2020 at 07:34:39PM +0200, Danny Milosavljevic wrote:
Toggle quote (8 lines)> UNIX has its warts, and this is a well-known one (use ${HOME} instead).> > If we did expanduser, I'm sure we'd be seeing bug reports about paths where> there was a tilde in the actual file name, NOT as a expanduser mark.> > UNIX tools do what they do, and this wart is here to stay in a lot of tools.> Then at least make it consistent across all the tools UNIX has.
If it's true that this behaviour is more or less consistent in UNIX /POSIX, then I agree with Danny that we should leave it as is. And, Ihave noticed that ${HOME} is the way to go.
Z
Z
zimoun wrote on 30 Apr 2020 20:14
(name . Leo Famulari)(address . leo@famulari.name)
CAJ3okZ1qzCCVwC2jMAKYxo_-B-ZDasADqTQ_AE02qDX42kZYAg@mail.gmail.com
On Thu, 30 Apr 2020 at 19:53, Leo Famulari <leo@famulari.name> wrote:
Toggle quote (3 lines)> > UNIX tools do what they do, and this wart is here to stay in a lot of tools.> > Then at least make it consistent across all the tools UNIX has.
I do not have a clear opinion on the subject so I fall with theDanny's wise opinion.
T
T
Tobias Geerinckx-Rice wrote on 30 Apr 2020 21:21
87y2qcsst3.fsf@nckx
Hartmut, Zimoun,
Hartmut Goebel 写道:
Toggle quote (4 lines)> After processing options, guix need to "expanduser()" (as it is > called> in Python) on all arguments which are paths.
If any Python (or other) software does this, it's broken. File a bug there.
This is the wrong thing to do and makes the GNU system an inconsistent mess. …OK, *more* of an inconsistent, loveable, mess ;-)
It also makes
$ sudo guix system --load-path=~/path/tp/my/project …
and
$ sudo guix system -L ~/path/to/my/project -A mypackage …
suddenly result in different file names.
Please don't do it.
Kind regards,
T G-R
-----BEGIN PGP SIGNATURE-----
iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXqslHwAKCRANsP+IT1VteVTOAP9kAgyVgt1j+wlg2CTHh29MK+iYy7IFvAsGIGeSXnrroAEAmME/0lyS3PCRAIwEbPlwu9cri6AQbhtdB8EXf0k08AM==8af+-----END PGP SIGNATURE-----
Z
Z
zimoun wrote on 30 Apr 2020 22:54
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 40977@debbugs.gnu.org)
CAJ3okZ0mLs3bZwZSGuawVovUdGWJu9BH1XmfG7KVsv0RDWohvQ@mail.gmail.com
Hi Tobias,
On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
Toggle quote (25 lines)>> Hartmut, Zimoun,>> Hartmut Goebel 写道:> > After processing options, guix need to "expanduser()" (as it is> > called> > in Python) on all arguments which are paths.>> If any Python (or other) software does this, it's broken. File a> bug there.>> This is the wrong thing to do and makes the GNU system an> inconsistent mess. …OK, *more* of an inconsistent, loveable, mess> ;-)>> It also makes>> $ sudo guix system --load-path=~/path/tp/my/project …>> and>> $ sudo guix system -L ~/path/to/my/project -A mypackage …>> suddenly result in different file names.
Sorry to be slow. Naive questions.
Do you mean the issue comes from who expand '~' (user vs sudo)?Or do you mean refer to subfolder named '~, i.e., $HOME/foo/~/bar?
I should miss a point... about what is less or more inconsistent. :-)Because it seems more based on conventions than on consistent inconsistencies.
About expansion, is it not the same question with'--load-path=$HOME/path/to/' vs '-L $HOME/path/to/'?About naming, is it possible to create a folder named '~' directly in $HOME?
Well, I am surely not enough skilled to have an opinion but I havelearnt something. :-)

Toggle quote (2 lines)> Please don't do it.
The fact that Guile does not have a built-in ``expand-tilde`` is astrong indication to not do it. ;-)

Cheers,simon
B
B
Bengt Richter wrote on 1 May 2020 08:51
(name . zimoun)(address . zimon.toutoune@gmail.com)
20200501065120.GA8427@LionPure
On +2020-04-30 22:54:47 +0200, zimoun wrote:
Toggle quote (44 lines)> Hi Tobias,> > On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:> >> > Hartmut, Zimoun,> >> > Hartmut Goebel 写道:> > > After processing options, guix need to "expanduser()" (as it is> > > called> > > in Python) on all arguments which are paths.> >> > If any Python (or other) software does this, it's broken. File a> > bug there.> >> > This is the wrong thing to do and makes the GNU system an> > inconsistent mess. …OK, *more* of an inconsistent, loveable, mess> > ;-)> >> > It also makes> >> > $ sudo guix system --load-path=~/path/tp/my/project …> >> > and> >> > $ sudo guix system -L ~/path/to/my/project -A mypackage …> >> > suddenly result in different file names.> > Sorry to be slow. Naive questions.> > Do you mean the issue comes from who expand '~' (user vs sudo)?> Or do you mean refer to subfolder named '~, i.e., $HOME/foo/~/bar?> > I should miss a point... about what is less or more inconsistent. :-)> Because it seems more based on conventions than on consistent inconsistencies.> > About expansion, is it not the same question with> '--load-path=$HOME/path/to/' vs '-L $HOME/path/to/'?> About naming, is it possible to create a folder named '~' directly in $HOME?> > Well, I am surely not enough skilled to have an opinion but I have> learnt something. :-)>
FYA:(Amusement): man bash to see what more ~ can lead to ;-)(scroll down or search for the "Tilde Expansion" section)
Toggle quote (13 lines)> > > Please don't do it.> > The fact that Guile does not have a built-in ``expand-tilde`` is a> strong indication to not do it. ;-)> > > Cheers,> simon> > >
-- Regards,Bengt Richter
Z
Z
zimoun wrote on 1 May 2020 17:24
(address . 40977@debbugs.gnu.org)
CAJ3okZ03nmo-JABJ-YNs9YLpBm2Hr_YWX9hns8KCENS2aMpehQ@mail.gmail.com
Dear,
Sorry to be slow.

On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
Toggle quote (6 lines)> Hartmut Goebel 写道:
> This is the wrong thing to do and makes the GNU system an> inconsistent mess. …OK, *more* of an inconsistent, loveable, mess> ;-)
I still think that the behaviour of Guix could be considered as a bugand inconsistent with other GNU tools, such as Emacs -- to pick onebut Emacs should be an exception in the GNU tools landscape(inconsistent loveable mess :-))
Maybe what I am saying is irrelevant and only bikeshedding.Like Saint-Thomas, I only believe that I see. ;-)

Toggle quote (10 lines)> It also makes>> $ sudo guix system --load-path=~/path/tp/my/project …>> and>> $ sudo guix system -L ~/path/to/my/project -A mypackage …>> suddenly result in different file names.
Emacs behaves differently; and it is what is expected (at least by me :-)).
Toggle snippet (18 lines)mkdir -p ${HOME}/tmp/foocat <<EOF > ${HOME}/tmp/foo/eg.el(defun an-example () (interactive) (message (car load-path)) (message (expand-file-name "kikoo" "~/foo/~/bar")))
(provide 'eg)EOF
# ~ means /home/simon/sudo emacs --batch -L ~/tmp/foo/ --eval "(require 'eg)" --eval "(an-example)"
# ~ mean /root/sudo emacs --batch --directory=~/tmp/foo/ --eval "(require 'eg)"--eval "(an-example)"
The first '~' is expanded by the shell so in the user's context. Thesecond '~' is expanded by Emacs so in the root's context.Well, nothing new. :-)This is not the issue, if I understand correctly.
This issue is about the subfolders named '~'.
Toggle snippet (20 lines)mkdir -p ${HOME}/tmp/foo/~/bar
cat <<EOF > ${HOME}/tmp/foo/~/bar/ex.el(defun from-tilde () (interactive) (message (car load-path)) (message (expand-file-name "yahoga" "~/foo/~/bar")))
(provide 'ex)EOF
cd ${HOME}/tmp/foo
# ~ means /home/simonemacs --batch --directory=~/bar/ --eval "(require 'ex)" --eval "(from-tilde)"
# protect ~emacs --batch --directory=./~/bar/ --eval "(require 'ex)" --eval "(from-tilde)"
From the folder '${HOME}/foo', Emacs is run with prepending thesubfolder named '~'. The first line fails because the folder'/home/simon/bar/' does not exist. The second '~' refers to thecorrect subfolder because of the dot.
Now the behaviour of Emacs is inconsistent with the Guix's behaviour.
Toggle snippet (4 lines)cd ${HOME}/fooguix show --load-path=~/bar from-tilde
This works. Because Guix uses the argument as it is. Note that'--load-path=./~/bar/' works too.
And note that from the folder '$HOME/tmp/foo', the commands
guix show -L ~/bar from-tilde
and
guix show --load-path=~/bar from-tilde
refer to different file names. And it appears to me weirder than thetilde expansion done as Emacs does.

Toggle snippet (16 lines)mkdir -p ${HOME}/tmp/foo/~/barcat <<EOF > ${HOME}/tmp/foo/~/bar/from-tilde.scm(define-module (from-tilde) #:use-module (guix packages) #:use-module (gnu packages maths))
(pk (car %load-path))
(define-public from-tilde (package (inherit gmsh) (name "from-tilde")))EOF

Toggle quote (2 lines)> Please don't do it.
Well, in summary.I have no knowledge about GNU tools and how they expand '~'.I agree that '~' could be considered as a wart. And I do not know ifconsidering '~' as shortcut for $HOME is a "good practise" or not.
But I use '~' as meaning $HOME more more often than I create anobscure subfolder named '~' (well I never did :-)). And I treat withcare the filename when I use 'sudo' because it is context switch so soerror-prone.
Maybe wrong terminology has been used with 'expanduser' but Guixshould expand '~' in agreement with the GNU Bash tilde-expansionsection IMHO.
(And this is valid for any '--long-option=~'.)

Therefore does the "it" in the Danny's and Tobias's "don't do it" meantilde-expansion?

Sorry again to be slow or bikeshed.
Best regards,simon
L
L
Ludovic Courtès wrote on 2 May 2020 15:14
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87k11u8oo6.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:
Toggle quote (7 lines)>> After processing options, guix need to "expanduser()" (as it is called>> in Python) on all arguments which are paths. >> Please don't do it.>> UNIX has its warts, and this is a well-known one (use ${HOME} instead).
Seconded.
Tilde expansion is performed by the shell. In the case of‘--foo=~/bar’, tilde expansion does not happen because ~ is right in themiddle of a string.
It’s admittedly annoying, but it’s not something Guix itself shouldpaper over. Doing that would open a can of worms, as illustrated by theexample Tobias gave.
Ludo’.
L
L
Ludovic Courtès wrote on 2 May 2020 15:14
control message for bug #40977
(address . control@debbugs.gnu.org)
87imhe8ont.fsf@gnu.org
tags 40977 notabugclose 40977quit
Z
Z
zimoun wrote on 2 May 2020 15:55
Re: bug#40977: --load-path does not honor ~
(name . Ludovic Courtès)(address . ludo@gnu.org)
CAJ3okZ231BEc2pnkn9cikP4PY6xY4+ywPcuhpYObFsXW7U=zBQ@mail.gmail.com
On Sat, 2 May 2020 at 15:14, Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (4 lines)> It’s admittedly annoying, but it’s not something Guix itself should> paper over. Doing that would open a can of worms, as illustrated by the> example Tobias gave.
Instead of 'notabug' , I propose to tag this bug as 'wontfix' andretitle it as: "Tilde-expansion in --long-options=".
Is it ok?

Best regards,simon
ps:Quoting the 'wontfix' explanation [1]: ``this is a choice between twoarbitrary ways of doing things and the maintainer and submitter preferdifferent ways of doing things``.[1] https://debbugs.gnu.org/Developer.html#tags
L
L
Ludovic Courtès wrote on 3 May 2020 00:14
(name . zimoun)(address . zimon.toutoune@gmail.com)
87mu6q2ddi.fsf@gnu.org
zimoun <zimon.toutoune@gmail.com> skribis:
Toggle quote (11 lines)> On Sat, 2 May 2020 at 15:14, Ludovic Courtès <ludo@gnu.org> wrote:>>> It’s admittedly annoying, but it’s not something Guix itself should>> paper over. Doing that would open a can of worms, as illustrated by the>> example Tobias gave.>> Instead of 'notabug' , I propose to tag this bug as 'wontfix' and> retitle it as: "Tilde-expansion in --long-options=".>> Is it ok?
Sure.
Ludo’.
Z
Z
zimoun wrote on 3 May 2020 17:19
(address . control@debbugs.gnu.org)
CAJ3okZ2oo9BmCXqBet+tg4iKfeX-X9croD1H5eeHp8BHB8p_5g@mail.gmail.com
tags 40977 - notabugtags 40977 wontfixretitle 40977 Tilde-expansion in --long-options=thanks
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send email to 40977@debbugs.gnu.org