unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29122: eshell passes ARGV[0] as full path to executable
@ 2017-11-03  7:33 Yegor Timoshenko
  2017-11-03  8:30 ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Yegor Timoshenko @ 2017-11-03  7:33 UTC (permalink / raw)
  To: 29122

In M-x eshell.

Given this program in C in file example.c:

#include <stdio.h>
int main(int argc, char *argv[]) { puts(argv[0]); }

$ cc example.c
$ ./a.out
/home/chronos/a.out

This prints full path to the executable instead of passing the actual
ARGV[0]. In other shells, say bash, ./a.out will result in `./a.out`
being printed to stdout.

$ emacs-repository-get-version
cb185dfd0c227dda14de25d450d0d684e91cafb3
$ emacs-version
GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.24)
 of 2017-10-28

This is a recent build from master. This bug is also reproducible on
latest stable release, 25.3.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#29122: eshell passes ARGV[0] as full path to executable
  2017-11-03  7:33 bug#29122: eshell passes ARGV[0] as full path to executable Yegor Timoshenko
@ 2017-11-03  8:30 ` Noam Postavsky
  2017-11-03  8:54   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Noam Postavsky @ 2017-11-03  8:30 UTC (permalink / raw)
  To: Yegor Timoshenko; +Cc: 29122

severity 29122 wishlist
quit

Yegor Timoshenko <yegortimoshenko@gmail.com> writes:

> $ ./a.out
> /home/chronos/a.out
>
> This prints full path to the executable instead of passing the actual
> ARGV[0].

Hmm, I don't think that's really a bug though.

> In other shells, say bash, ./a.out will result in `./a.out`
> being printed to stdout.

eshell is not a bash emulation.

> This is a recent build from master. This bug is also reproducible on
> latest stable release, 25.3.

At any rate, to change this would require adding some option to
make-process, as presently Emacs provides no way of calling a process
with argv[0] different from the called executable.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#29122: eshell passes ARGV[0] as full path to executable
  2017-11-03  8:30 ` Noam Postavsky
@ 2017-11-03  8:54   ` Eli Zaretskii
       [not found]     ` <CAF4sQCM56=6y=1Lrg9RAQo+ui2kRSqRVHiarYYX=i6FGDv3C_A@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2017-11-03  8:54 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: yegortimoshenko, 29122

> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Fri, 03 Nov 2017 04:30:29 -0400
> Cc: 29122@debbugs.gnu.org
> 
> > $ ./a.out
> > /home/chronos/a.out
> >
> > This prints full path to the executable instead of passing the actual
> > ARGV[0].
> 
> Hmm, I don't think that's really a bug though.

It isn't, IMO.  AFAIK, whether the value of argv[0] is an absolute
file name or not, and whet it is, depends on the shell and on the
other circumstances.

> At any rate, to change this would require adding some option to
> make-process, as presently Emacs provides no way of calling a process
> with argv[0] different from the called executable.

I'm not sure we should make such changes.  Programs that rely on
whether argv[0] is absolute or not are unportable at best, and should
be fixed, rather than blaming this on the shell.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#29122: eshell passes ARGV[0] as full path to executable
       [not found]     ` <CAF4sQCM56=6y=1Lrg9RAQo+ui2kRSqRVHiarYYX=i6FGDv3C_A@mail.gmail.com>
@ 2017-11-03 10:02       ` Eli Zaretskii
  2017-12-13  3:29         ` Noam Postavsky
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2017-11-03 10:02 UTC (permalink / raw)
  To: Yegor Timoshenko; +Cc: 29122

> From: Yegor Timoshenko <yegortimoshenko@gmail.com>
> Date: Fri, 3 Nov 2017 09:22:59 +0000
> 
> The use case here is when programs print usage information.
> 
> Usage: ./a.out command [arguments...]
> Usage: /home/user/path/to/a.out command [arguments...]
> 
> The former reads better and is generally expected from shells.

You will get the same problem when a.out is found by searching PATH.
And on Windows, your program will almost always get argv[0] in
absolute form.  So you need to take care of that anyway, or else your
program will sometimes produce that less readable output.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#29122: eshell passes ARGV[0] as full path to executable
  2017-11-03 10:02       ` Eli Zaretskii
@ 2017-12-13  3:29         ` Noam Postavsky
  0 siblings, 0 replies; 5+ messages in thread
From: Noam Postavsky @ 2017-12-13  3:29 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Yegor Timoshenko, 29122

tags 29122 wontfix
close 29122
quit

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Yegor Timoshenko <yegortimoshenko@gmail.com>
>> Date: Fri, 3 Nov 2017 09:22:59 +0000
>> 
>> The use case here is when programs print usage information.
>> 
>> Usage: ./a.out command [arguments...]
>> Usage: /home/user/path/to/a.out command [arguments...]
>> 
>> The former reads better and is generally expected from shells.
>
> You will get the same problem when a.out is found by searching PATH.
> And on Windows, your program will almost always get argv[0] in
> absolute form.  So you need to take care of that anyway, or else your
> program will sometimes produce that less readable output.

Therefore closing as wontfix.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-13  3:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03  7:33 bug#29122: eshell passes ARGV[0] as full path to executable Yegor Timoshenko
2017-11-03  8:30 ` Noam Postavsky
2017-11-03  8:54   ` Eli Zaretskii
     [not found]     ` <CAF4sQCM56=6y=1Lrg9RAQo+ui2kRSqRVHiarYYX=i6FGDv3C_A@mail.gmail.com>
2017-11-03 10:02       ` Eli Zaretskii
2017-12-13  3:29         ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).