bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash: no job control in this shell


From: JimK
Subject: Re: bash: no job control in this shell
Date: Mon, 9 Jul 2007 04:58:59 -0700 (PDT)


Bob Proulx wrote:
> 
> 
>>Internally bash will use the libc isatty(3) routine to determine if
>>the input/output files are tty devices.  In the shell these are
>>available in the 'test' operator as the '-t' file operator.
> 
>>  $ test -t 0 && echo input is a tty
>>  $ test -t 1 && echo output is a tty
> 
> these both reported is a tty
> 
>>The technique I have used is to look at $-, the option flags, and see
>>if 'i' is present there.
> 
>>       PS1 is set and $- includes I if bash is interactive, allowing a
>>       shell script or a startup file to test this state.
> 
>>Something like this works:
> 
>>  case $- in
>>    *i*) echo shell is interactive ;;
>>  esac
> 
>>Other people prefer to use a test for PS1 such as this example.
> 
>>  test "${PS1+set}" = set && echo shell is interactive
> 
> this reported interactive as well
> 
>>It would be useful to see what 'stty -a' reports.  That will dump the
>>current tty settings, if it is a tty.  I will simulate not being on a
>>tty by redirecting from /dev/null.
> 
>>  $ stty -a </dev/null
>>  stty: standard input: Inappropriate ioctl for device
> 
>>On a valid tty it will dump the current settings.
> 
>>  $ stty -a 
>>  speed 38400 baud; rows 24; columns 80; line = 0;
>>  intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
>>  eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt
>> = ^R;
>>  werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
>>  -parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
>>  -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon
>> -ixoff
>>  -iuclc -ixany -imaxbel -iutf8
>>  opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0
>> vt0 ff0
>>  isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop
>> -echoprt
>>  echoctl echoke
> 
> isatty reported the exact same results as above.
> 
>>Sorry but I don't have any hints for you there.  Personally I would
>>need to learn how setting up ptys is typically done these days, such
>>as by inspecting how 'xterm' or 'expect' or other such programs do
>>this.  As I recall Marc Rochkind discusses this operation in detail in
>>his book "Advanced UNIX Programming" and therefore might be a good
>>reference.  A lot of best practices have changed since the last time I
>>set up a master-slave pty pair and I only remember the old ways.
> 
>>Bob
> 
> So it appears my shell is interactive, will follow up looking into ptys in
> Advanced UNIX Programming.
> Appreciate the info and suggestions ...
> 
> 

-- 
View this message in context: 
http://www.nabble.com/bash%3A-no-job-control-in-this-shell-tf3995540.html#a11500292
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]