Re: [PATCH] FIGNORE: ignore results that are exactly equal to a suffix

2023-04-20 Thread Chet Ramey

On 4/16/23 10:08 PM, Emanuele Torre wrote:

FIGNORE makes bash only ignore filename completion results that end with
one of the specified suffixes and are not exactly equal to the suffix.


Yes. It requires a non-empty prefix and has since I first added it in
January, 1991 (based on an earlier contribution, so it's truly ancient).

Backwards compatibility is important, but I think it's also important to
look at the behavior of tcsh's `fignore', which is what this feature is
supposed to emulate.

It turns out that tcsh behaves like you propose, so your patch looks good.

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: SIGINT not breaking loop with non-list function body

2023-04-20 Thread Chet Ramey

On 4/19/23 4:55 PM, Grisha Levit wrote:

If an interactive shell line is just a single loop and the body of the loop
consists only of a function name, and the function body is not a list, ^C
does not cause the loop to break as it otherwise would.


Thanks for the report.


This code in wait_for seems to be the only place where the value of
executing_list is tested, so maybe changing that variable to something like
executing_list_or_loop and adding in/decrements of it in the loop-related
execute_* functions would make sense.


I added something very similar to this.

--
``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: How difficult would it be to add a timeout to "wait"?

2023-04-20 Thread Chet Ramey

On 4/20/23 1:53 PM, Dale R. Worley wrote:

How difficult would it be to add an optional timeout argument to the
"wait" builtin?


Try a variant of this.

trap 'echo timeout!' USR1 # choose your fighter

wait_with_timeout()
{
pid=$1
timeout=$2

{ sleep $timeout && kill -USR1 $$; } & tpid=$!

wait $pid
stat=$?

kill -TERM $tpid 2>/dev/null

return $stat
}

{ sleep 10; exit 42; } &
pid=$!
wait_with_timeout $pid 5# will time out
echo $?

wait_with_timeout $pid 10   # won't time out
echo $?


--
``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/




How difficult would it be to add a timeout to "wait"?

2023-04-20 Thread Dale R. Worley
How difficult would it be to add an optional timeout argument to the
"wait" builtin?

I occasionally run into situations where this functionality is
desirable, more often than I expect, really.  And though the last thing
Bash needs is an additional feature, naively it seems like it wouldn't
be too difficult.  E.g. "read" already has a timeout feature.

But I looked into the code, and all the variations and implementations
of "wait" map reasonably directly into one or another of the Posix
"wait" calls.  I'm no expert there, but I tried looking and there
doesn't seem to be any version of those that allows the program to
specify a timeout time.  I considered setting an alarm() before calling
wait() but a quick look on Stack Overflow said that is a good way to
lose the status information from child jobs.

Dale