Re: a patch to fix sh_stat on SunOS

2016-08-24 Thread Chet Ramey
On 8/23/16 8:28 PM, Dmitry Goncharov wrote: > On Mon, Aug 22, 2016 at 11:04:24AM -0400, Chet Ramey wrote: >> I'd rather it were done via an explicit switch to configure. I'd look at >> a patch to do that. >> > The patch in the attachment is against the top of master of > git://git.savannah.gnu.org

Re: a patch to fix sh_stat on SunOS

2016-08-22 Thread Chet Ramey
On 8/21/16 10:36 PM, Dmitry Goncharov wrote: >> But why should bash override the semantics that an OS provides for >> /dev/fd, resulting in differing behavior between the shell and other >> utilities with the same pathname argument? > > For the benefit of the user. Currently bash behavior is diff

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Dmitry Goncharov
On Sun, Aug 21, 2016 at 03:04:07PM -0400, Chet Ramey wrote: > The current text in redirection says: > > Bash handles several filenames specially when they are used in redirec- >tions, as described in the following table. If the operating system on >which bash is running provides t

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Dmitry Goncharov
On Sun, Aug 21, 2016 at 04:03:05PM -0400, Grisha Levit wrote: > On Aug 20, 2016 9:32 PM, "Dmitry Goncharov" wrote: > > With this new contract how can the user write portable bash code which > tests if a fd refers to a pipe? > > The test command seems to have the behavior you expect. > > $ uname

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Grisha Levit
On Aug 20, 2016 9:32 PM, "Dmitry Goncharov" wrote: > With this new contract how can the user write portable bash code which tests if a fd refers to a pipe? The test command seems to have the behavior you expect. $ uname SunOS $ mkfifo /tmp/pipe $ cat < /tmp/pipe & [1] 25376 $ exec 6>/tmp/pipe $

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Chet Ramey
On 8/20/16 9:31 PM, Dmitry Goncharov wrote: > On Thu, Aug 11, 2016 at 07:52:51AM -0400, Chet Ramey wrote: >> On 8/10/16 5:38 PM, Dmitry Goncharov wrote: >> > does "If any file argument to one of the primaries is of the form >>> > /dev/fd/n, then file descriptor n is checked.". >>> >>>

Re: a patch to fix sh_stat on SunOS

2016-08-20 Thread Dmitry Goncharov
On Thu, Aug 11, 2016 at 07:52:51AM -0400, Chet Ramey wrote: > On 8/10/16 5:38 PM, Dmitry Goncharov wrote: > > >> > does "If any file argument to one of the primaries is of the form > > > >> > /dev/fd/n, then file descriptor n is checked.". > > > > > >> It seems like a documentation error. > >

Re: a patch to fix sh_stat on SunOS

2016-08-11 Thread Chet Ramey
On 8/10/16 5:38 PM, Dmitry Goncharov wrote: >> > does "If any file argument to one of the primaries is of the form > >> > /dev/fd/n, then file descriptor n is checked.". > > >> It seems like a documentation error. > > What should the man page say instead? Probably something close to what the

Re: a patch to fix sh_stat on SunOS

2016-08-10 Thread Dmitry Goncharov
On Wed, Aug 10, 2016 at 10:30 AM, Chet Ramey wrote: > > On 8/10/16 10:19 AM, Dmitry Goncharov wrote: > > > bash does not do what the following quote from the bash man page says it > > > does "If any file argument to one of the primaries is of the form > > > /dev/fd/n, then file descriptor n is

Re: a patch to fix sh_stat on SunOS

2016-08-10 Thread Chet Ramey
On 8/10/16 10:19 AM, Dmitry Goncharov wrote: > > > On Wed, Aug 10, 2016 at 9:56 AM, Chet Ramey > wrote: > >> So what you're saying is that you don't like how SunOS implements /dev/fd > >> and you'd like bash to override the native implementation semantics. > > i do

Re: a patch to fix sh_stat on SunOS

2016-08-10 Thread Dmitry Goncharov
On Wed, Aug 10, 2016 at 9:56 AM, Chet Ramey wrote: > So what you're saying is that you don't like how SunOS implements /dev/fd > > and you'd like bash to override the native implementation semantics. i don't care how sunos implements /dev/fd. i care that bash fails on sunos. bash does not do wh

Re: a patch to fix sh_stat on SunOS

2016-08-10 Thread Chet Ramey
On 8/9/16 9:12 PM, Dmitry Goncharov wrote: > Good morning, > > The following piece of shell code does not work on sunos. > mkfifo /tmp/pipe > cat < /tmp/pipe & > exec 6>/tmp/pipe > test -p /dev/fd/6 && echo pipe > > The reason is on sunos /dev/fd/6 is a special character file, not a pipe > (unlik

a patch to fix sh_stat on SunOS

2016-08-10 Thread Dmitry Goncharov
Good morning, The following piece of shell code does not work on sunos. mkfifo /tmp/pipe cat < /tmp/pipe & exec 6>/tmp/pipe test -p /dev/fd/6 && echo pipe The reason is on sunos /dev/fd/6 is a special character file, not a pipe (unlike bsd), not a symlink (unlike linux, cygwin). sh_stat ends up c