Re: give_terminal_to after re-backgrounded async job

2023-07-10 Thread Chet Ramey

On 7/7/23 12:43 PM, Grisha Levit wrote:

The fix [1] for the issue reported in [2]:

+ give the terminal to pipeline_pgrp. We don't give the terminal
+ back to shell_pgrp if an async job exits because we never gave it
+ to that job in the first place. */
if ((flags & JWAIT_NOTERM) == 0 && running_in_background == 0 &&
+  (job == NO_JOB || IS_ASYNC (job) == 0) &&
(subshell_environment & (SUBSHELL_ASYNC|SUBSHELL_PIPE)) == 0)
   give_terminal_to (shell_pgrp, 0);

makes bash not take the terminal back when an async job is brought to the
foreground with `fg' and then subsequently TSTP-ed.


Thanks for the report; easy fix.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: leak in command_word_completion_function

2023-07-10 Thread Chet Ramey

On 7/7/23 5:35 PM, Grisha Levit wrote:

If there a glob is expanded to more than one result while attempting
to complete the command word, the matches are discarded but not freed.


Thanks for the report.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: [PATCH] confusing/obsolete handling of test -t operator (and doc warnings against using -o/-a)

2023-07-10 Thread Chet Ramey

On 7/8/23 3:18 AM, Stephane Chazelas wrote:

2023-07-07 15:52:28 -0400, Chet Ramey:
[...]

Historical versions of test made the argument to -t optional here. I can
continue to support that in default mode for backwards compatibility, but
it will be an error in posix mode.

[...]

I think you may have overlooked the bottom part of my email
(possibly because it was hidden by your MUA as it included
quoted text) that included comments on the code and a patch.


I didn't.


bash hasn't supported [ -t ] as an alias for [ -t 1 ] since 2.02
and possibly earlier AFAICT since it started supporting the
POSIX rules where [ any-non-empty-single-argument ] returns
true, and having [ -t ] to check whether stdout is a terminal is
not allowed.


I'm not talking about changing any of the cases that POSIX specifies. I'm
talking about the historical behavior when supplied 4 (in some cases) or
5+ arguments.


The problem here is that some code to support that haven't been
removed at the time the POSIX rules were implemented. The patch
I suggested just removes that code.


I saw it.


ksh93 does support [ -t ] when the -t is literal:


That's not POSIX conformant, so it's out.



I also noticed that the fact that -a/-o were deprecated (by POSIX at
least) and made for unreliable test expressions was not noted in the
manual. So I suggest the patch below:


I added some language about this, noting that POSIX has deprecated them
and recommending scripts not use them. Thanks for the suggestion.

[...]

Note that "(" and ")" are also obsoleted by POSIX and as a
result any usage of test with 5 or more arguments (hence why I
flagged them as (DEPRECATED) in the doc patch I was suggesting.


That's in there.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/