Re: [PATCH] fdflags: fix -s with multiple flags, and multiple fd arguments

2023-11-14 Thread Chet Ramey

On 11/5/23 8:51 AM, Emanuele Torre wrote:

fdflags -s  was re-parsing the setspec for each fd argument.
This is problematic because it is using  strtok()  to parse it
destructively.
So, only the first part of the setspec will be set for all file
descriptors; the other parts will only be set for the first file
descriptor:


Thanks for the report.

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/




[PATCH] fdflags: fix -s with multiple flags, and multiple fd arguments

2023-11-05 Thread Emanuele Torre
fdflags -s  was re-parsing the setspec for each fd argument.
This is problematic because it is using  strtok()  to parse it
destructively.
So, only the first part of the setspec will be set for all file
descriptors; the other parts will only be set for the first file
descriptor:

  $ enable fdflags
  $ exec {foo1} /dev/null
  $ fdflags -- "$foo1" "$foo2"
  10:nonblock,cloexec
  11:nonblock
  $ exec {foo1}<&- {foo2}<&- {foo3}next)
 {
@@ -335,7 +336,7 @@ fdflags_builtin (WORD_LIST *list)
}
   num = inum;  /* truncate to int */
   if (setflag)
-   setone (num, setspec, verbose);
+   setone (num, setpos, setneg, verbose);
   else
printone (num, 1, verbose);
 }
-- 
2.42.0