Re: bash build

2012-06-02 Thread Clark WANG
On Sat, Jun 2, 2012 at 7:39 AM, rac8006  wrote:
>
> What is the proper way to add popd pushd dirs etc to bash.  When I currently
> build bash these

By default those commands should be enabled. I never added special
options when buidling Bash. Not sure if it's system dependent. But
from the "configure --help" output I found this:

  --enable-directory-stackenable builtins pushd/popd/dirs

You can try if that helps. :)

> are missing.  I also get an error libintl_ngettext undefined reference.  I
> can get around this error
> by adding -lintl to the link.  Just don't know how to get the Makefile to
> add -lintl.
>
> Thanks for your help
>
> RAC
> --
> View this message in context: 
> http://old.nabble.com/bash-build-tp33947830p33947830.html
> Sent from the Gnu - Bash mailing list archive at Nabble.com.
>
>



.bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Mikel Ward
bash sources .bashrc even for some non-interactive shells.

For example with

echo \$- is $-

in ~/.bashrc, and shell set to /bin/bash (bash 4.2.28)

ssh -n -T localhost true

produces the output

$- is hBc

I assume this is caused by this code in shell.c

 if (run_by_ssh || isnetconn (fileno (stdin)))

The man page says

   When an interactive shell that is not a login shell is started,
bash reads and executes commands from ~/.bashrc,

but makes no mention of the special handling for ssh and rsh.

This seems to have been the case since at least bash 2.02.

I'd argue this is a misfeature, but I guess that ship has sailed.  Can
the man page at least be updated?

Thanks



Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Pierre Gaston
On Sat, Jun 2, 2012 at 8:15 PM, Mikel Ward  wrote:
> bash sources .bashrc even for some non-interactive shells.
>
> For example with
>
>    echo \$- is $-
>
> in ~/.bashrc, and shell set to /bin/bash (bash 4.2.28)
>
>    ssh -n -T localhost true
>
> produces the output
>
>    $- is hBc
>
> I assume this is caused by this code in shell.c
>
>     if (run_by_ssh || isnetconn (fileno (stdin)))
>
> The man page says
>
>       When an interactive shell that is not a login shell is started,
> bash reads and executes commands from ~/.bashrc,
>
> but makes no mention of the special handling for ssh and rsh.
>
> This seems to have been the case since at least bash 2.02.
>
> I'd argue this is a misfeature, but I guess that ship has sailed.  Can
> the man page at least be updated?
>
> Thanks
>
>From http://mywiki.wooledge.org/DotFiles:

"Remote non login non interactive shells"
Bash has a special compile time option that will cause it to source
the .bashrc file on non-login, non-interactive ssh sessions. This
feature is only enabled by certain OS vendors (mostly Linux
distributions). It is not enabled in a default upstream Bash build,
and (empirically) not on OpenBSD either.

If this feature is enabled on your system, Bash detects that
SSH_CLIENT or SSH_CLIENT2 is in the environment and in this case
source .bashrc. eg suppose you have var=foo in your remote .bashrc and
you do: ssh remotehost echo \$var it will print foo.

This shell is non-interactive so you can test $- or $PS1, if you don't
want things to be executed this way in your .bashrc.

Without this option bash will test if stdin is connected to a socket
and will also source .bashrc in this case BUT this test fails if you
use a recent openssh server (>5.0) which means that you will probably
only see this on older systems.

Note that a test on SHLVL is also done, so if you do: ssh remotehost
bash -c echo then the first bash will source .bashrc but not the
second one (the explicit bash on the command line that runs echo).

The behaviour of the bash patched to source a system level bashrc by
some vendors is left as an exercise.



Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Mikel Ward
Apologies.  It's mentioned a few paragraphs further down.

Can I suggest a change?

How about instead of:

   When an interactive shell that is not a login shell is started

something like:

   When a shell is started that is not a login shell, but is
either an interactive shell or a network shell

On Sat, Jun 2, 2012 at 10:15 AM, Mikel Ward  wrote:
> bash sources .bashrc even for some non-interactive shells.
>
> For example with
>
>    echo \$- is $-
>
> in ~/.bashrc, and shell set to /bin/bash (bash 4.2.28)
>
>    ssh -n -T localhost true
>
> produces the output
>
>    $- is hBc
>
> I assume this is caused by this code in shell.c
>
>     if (run_by_ssh || isnetconn (fileno (stdin)))
>
> The man page says
>
>       When an interactive shell that is not a login shell is started,
> bash reads and executes commands from ~/.bashrc,
>
> but makes no mention of the special handling for ssh and rsh.
>
> This seems to have been the case since at least bash 2.02.
>
> I'd argue this is a misfeature, but I guess that ship has sailed.  Can
> the man page at least be updated?
>
> Thanks



Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Mikel Ward
On Sat, Jun 2, 2012 at 10:19 AM, Pierre Gaston  wrote:
> On Sat, Jun 2, 2012 at 8:15 PM, Mikel Ward  wrote:
>> bash sources .bashrc even for some non-interactive shells.
...
> "Remote non login non interactive shells"
> Bash has a special compile time option that will cause it to source
> the .bashrc file on non-login, non-interactive ssh sessions.

IIUC, it was once a compile time option, but it's now hard-coded.  The
isnetconn test doesn't seem to be toggled by any macro.

  if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)



Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Pierre Gaston
On Sat, Jun 2, 2012 at 8:24 PM, Mikel Ward  wrote:
> On Sat, Jun 2, 2012 at 10:19 AM, Pierre Gaston  
> wrote:
>> On Sat, Jun 2, 2012 at 8:15 PM, Mikel Ward  wrote:
>>> bash sources .bashrc even for some non-interactive shells.
> ...
>> "Remote non login non interactive shells"
>> Bash has a special compile time option that will cause it to source
>> the .bashrc file on non-login, non-interactive ssh sessions.
>
> IIUC, it was once a compile time option, but it's now hard-coded.  The
> isnetconn test doesn't seem to be toggled by any macro.
>
>      if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
but  run_by_ssh is:

#ifdef SSH_SOURCE_BASHRC
  run_by_ssh = (find_variable ("SSH_CLIENT") != (SHELL_VAR *)0) ||
   (find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0);
#else
  run_by_ssh = 0;
#endif



link problem undefined reference tgoto BC & UP

2012-06-02 Thread rac8006

Why can't I get a clean compile of bash4.1?  I was building until I did a
configure --enable_progcomp
Now it fails with  the three missing symbols tgoto , BC and UP.  I've
searched this site with no answers.
Searched the web found references to -ltinfo.  But I don't have that
library.
What do I need to do to get a clean build?

RAC
-- 
View this message in context: 
http://old.nabble.com/link-problem-undefined-reference-tgoto-BC---UP-tp33950439p33950439.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




Re: link problem undefined reference tgoto BC & UP

2012-06-02 Thread Pierre Gaston
On Sat, Jun 2, 2012 at 8:55 PM, rac8006  wrote:
>
> Why can't I get a clean compile of bash4.1?  I was building until I did a
> configure --enable_progcomp
> Now it fails with  the three missing symbols tgoto , BC and UP.  I've
> searched this site with no answers.
> Searched the web found references to -ltinfo.  But I don't have that
> library.
> What do I need to do to get a clean build?

Hard to tell with so little and so imprecise information



Re: link problem undefined reference tgoto BC & UP

2012-06-02 Thread rac8006

I think I fixed my problem.  I compiled the ncurses library from the source
code for the DNS-323 NAS.
I used it to link bash.

RAC

Pierre Gaston wrote:
> 
> On Sat, Jun 2, 2012 at 8:55 PM, rac8006  wrote:
>>
>> Why can't I get a clean compile of bash4.1?  I was building until I did a
>> configure --enable_progcomp
>> Now it fails with  the three missing symbols tgoto , BC and UP.  I've
>> searched this site with no answers.
>> Searched the web found references to -ltinfo.  But I don't have that
>> library.
>> What do I need to do to get a clean build?
> 
> Hard to tell with so little and so imprecise information
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/link-problem-undefined-reference-tgoto-BC---UP-tp33950439p33950742.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Linda Walsh



Pierre Gaston wrote:


On Sat, Jun 2, 2012 at 8:24 PM, Mikel Ward  wrote:

On Sat, Jun 2, 2012 at 10:19 AM, Pierre Gaston  wrote:

On Sat, Jun 2, 2012 at 8:15 PM, Mikel Ward  wrote:

bash sources .bashrc even for some non-interactive shells.

...

"Remote non login non interactive shells"
Bash has a special compile time option that will cause it to source
the .bashrc file on non-login, non-interactive ssh sessions.

IIUC, it was once a compile time option, but it's now hard-coded. �The
isnetconn test doesn't seem to be toggled by any macro.

� � �if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)

but  run_by_ssh is:

#ifdef SSH_SOURCE_BASHRC
  run_by_ssh = (find_variable ("SSH_CLIENT") != (SHELL_VAR *)0) ||
   (find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0);
#else
  run_by_ssh = 0;
#endif




I would say that's broken -- bash can detect if it is
hooked up to a terminal for input, or not, but chooses not to.

prelude:

ans=("is "{not,}" a tty")
alias sub=function
sub echoAns { echo ${ans[$?==0]}; }
alias }{=else {=then }=fi ?=if

4 basic cases...

1)
Ishtar:...> if ssh  ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
.bashrc STDIN: is not a tty ( $-=hBc )
is not a tty


2)
Ishtar:...> if ssh -T ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
.bashrc STDIN: is not a tty ( $-=hBc )
is not a tty


3)
Ishtar:...> if ssh -tn ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
.bashrc STDIN: is not a tty ( $-=hBc )
is not a tty


4)
Ishtar:...> if ssh -t ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
.bashrc STDIN: is a tty ( $-=hBc )
is a tty

While it is arguable whether or not 1 & 2 are 'interactive' (they are but not in 
a character oriented way), #4, by:

   --rcfile file
  Execute commands from file instead of the standard personal ini-
  tialization file ~/.bashrc if  the  shell  is  interactive  (see
  INVOCATION below).
---Under invocation:
   An interactive shell is one started without  non-option  arguments  and
   without the -c option whose standard input and error are both connected
   to terminals .

  ***(as determined by isatty(3)),***

   or one started with  the  -i
   option.   PS1 is set and $- includes i if bash is interactive, allowing
   a shell script or a startup file to test this state.


By using the isatty test, none of 1-3 should be calling bashrc.
You can note that the "-i" switch isn't specified at any point.

Minimally I would claim #4 to be a bug, and from the manual, #1 and #2 are as
well.  (-n redirects STDIN from /dev/null -- a definite "non-winner for 
interactivity).










Re: .bashrc is sourced even for non-interactive shells (when run from sshd)

2012-06-02 Thread Pierre Gaston
On Sun, Jun 3, 2012 at 3:05 AM, Linda Walsh  wrote:
>
>
> Pierre Gaston wrote:
>
>> On Sat, Jun 2, 2012 at 8:24 PM, Mikel Ward  wrote:
>>>
>>> On Sat, Jun 2, 2012 at 10:19 AM, Pierre Gaston 
>>> wrote:

 On Sat, Jun 2, 2012 at 8:15 PM, Mikel Ward  wrote:
>
> bash sources .bashrc even for some non-interactive shells.
>>>
>>> ...

 "Remote non login non interactive shells"
 Bash has a special compile time option that will cause it to source
 the .bashrc file on non-login, non-interactive ssh sessions.
>>>
>>> IIUC, it was once a compile time option, but it's now hard-coded. �The
>>> isnetconn test doesn't seem to be toggled by any macro.
>>>
>>> � � �if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
>>
>> but  run_by_ssh is:
>>
>> #ifdef SSH_SOURCE_BASHRC
>>      run_by_ssh = (find_variable ("SSH_CLIENT") != (SHELL_VAR *)0) ||
>>                   (find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0);
>> #else
>>      run_by_ssh = 0;
>> #endif
>>
>
>
> I would say that's broken -- bash can detect if it is
> hooked up to a terminal for input, or not, but chooses not to.
>
> prelude:
>
> ans=("is "{not,}" a tty")
> alias sub=function
> sub echoAns { echo ${ans[$?==0]}; }
> alias }{=else {=then }=fi ?=if
>
> 4 basic cases...
>
> 1)
> Ishtar:...> if ssh  ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
> .bashrc STDIN: is not a tty ( $-=hBc )
> is not a tty
>
>
> 2)
> Ishtar:...> if ssh -T ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
> .bashrc STDIN: is not a tty ( $-=hBc )
> is not a tty
>
>
> 3)
> Ishtar:...> if ssh -tn ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
> .bashrc STDIN: is not a tty ( $-=hBc )
> is not a tty
>
>
> 4)
> Ishtar:...> if ssh -t ishtar isatty 0 2>/dev/null; { echoAns; }{ echoAns; }
> .bashrc STDIN: is a tty ( $-=hBc )
> is a tty
>
> While it is arguable whether or not 1 & 2 are 'interactive' (they are but
> not in a character oriented way), #4, by:
>       --rcfile file
>              Execute commands from file instead of the standard personal
> ini-
>              tialization file ~/.bashrc if  the  shell  is  interactive
>  (see
>              INVOCATION below).
> ---Under invocation:
>       An interactive shell is one started without  non-option  arguments
>  and
>       without the -c option whose standard input and error are both
> connected
>       to terminals .
>
>  ***(as determined by isatty(3)),***
>
>       or one started with  the  -i
>       option.   PS1 is set and $- includes i if bash is interactive,
> allowing
>       a shell script or a startup file to test this state.
>
>
> By using the isatty test, none of 1-3 should be calling bashrc.
> You can note that the "-i" switch isn't specified at any point.
>
> Minimally I would claim #4 to be a bug, and from the manual, #1 and #2 are
> as
> well.  (-n redirects STDIN from /dev/null -- a definite "non-winner for
> interactivity).

In all your examples the shell will be called like: bash -c  'isatty 0
2'. If you use a bash compiled with the above option you can add 'ps
-p$$ -ocmd' at the top of your .bashrc to verify it.

They are all non-interactive because they are called with -c,
disregarding if they are connected to a terminal or not.



lib/sh/mktime.c VMS specific code is not needed.

2012-06-02 Thread John Malmberg
The lib/sh/mktime.c module has a VMS specific include of  
to pick up time_t.


On VMS, the time_t type is defined in the  module.

So this VMS specific include can be removed.

Regards,
-John