[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [UX] real names exposed
From: |
Ludovic Courtès |
Subject: |
Re: [UX] real names exposed |
Date: |
Thu, 01 Sep 2016 10:59:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Bavier <address@hidden> skribis:
> On 2016-08-31 18:11, Leo Famulari wrote:
>> On Wed, Aug 31, 2016 at 02:25:49PM -0400, Troy Sankey wrote:
>>> I understand why this happens:
>>>
>>> % khal --help
>>> Usage: .khal-real [OPTIONS] COMMAND [ARGS]...
>>> [...]
>>>
>>> but I think it sorta sucks for user experience. Just thought I'd
>>> point this
>>> out, and I was wondering if there were any ideas to address this.
>>>
>>> Specifically, argv[0] references the name of the "real" executable,
>>> rather than
>>> the guix wrapper. This is almost always benign, but it looks ugly
>>> in help
>>> menus.
>>
>> I wonder if the Khal author (Christian) intends for users to rename the
>> executable. Otherwise, why use argv[0]? Is it some side-effect of a
>> documentation tool used by Khal?
>>
>> I would understand if khal and ikhal were the same executable, and
>> behavior was changed based on argv[0], but that's not the case.
>>
>> It does look ugly.
>
> It's not just khal. Most other executables and scripts that reference
> argv[0] or $0 end up with the *=real string.
>
> In our wrapper scripts, we pass -a to exec, which is supposed to
> address this issue, but for some reason it seems ineffective.
‘exec -a’ works as advertised:
--8<---------------cut here---------------start------------->8---
$ sh -c 'exec -a FOO guile -c "(pk (command-line))"'
;;; (("FOO"))
--8<---------------cut here---------------end--------------->8---
Yet:
--8<---------------cut here---------------start------------->8---
$ sh -c 'exec -a FOO
/gnu/store/6vmniz83k46l8jpry50wdvwxsncz1r5w-khal-0.7.0/bin/.khal-wrap-01
--version'
.khal-real, version 0.7.0
--8<---------------cut here---------------end--------------->8---
And in fact:
--8<---------------cut here---------------start------------->8---
$ cat > t.py
import sys
print(sys.argv[0])
$ sh -c 'exec -a FOO python3 t.py'
t.py
--8<---------------cut here---------------end--------------->8---
… even though argv[0] is initially correct:
--8<---------------cut here---------------start------------->8---
$ sh -c 'exec -a FOO python3 --help' | head -1
usage: FOO [option] ... [-c cmd | -m mod | file | -] [arg] ...
--8<---------------cut here---------------end--------------->8---
So somewhere, Python finds out the real name, but it doesn’t seem to be
via /proc/cmdline or anything like that, and I couldn’t find the exact
hack in the source.
Ideas?
I would really like to fix it in ‘core-updates’.
Ludo’.
- Re: [UX] real names exposed,
Ludovic Courtès <=