Re: simple prob?

2021-07-02 Thread Phi Debian
Ha ok, I got it, I was focused on our interactive session. Surely a script running on a UID behalf would be ill-advised to interpret (in the sense of shell evaluation) an arbitrary shell expression. On Fri, Jul 2, 2021 at 6:06 PM Greg Wooledge wrote: > On Fri, Jul 02, 2021 at 05:45:23PM +0200, P

Re: simple prob?

2021-07-02 Thread Greg Wooledge
On Fri, Jul 02, 2021 at 05:45:23PM +0200, Phi Debian wrote: > Regarding the code injection I am not sure I got it. > > If you are sitting at a prompt, why would you trick > > unicorn:~$ njobs_ref 'x[0$(date>&2)]' > > when you could simply type > unicorn:~$ date > > I assume protected script/sou

Re: simple prob?

2021-07-02 Thread Phi Debian
Ha yes I lost sight of <(jobs -t), I think it is a good improvement to the challenge :) Regarding the local t, you right, I missed to precise that any function that do output parameters via nameref should namespace all their locals and check the namespace that is indeed a bit combersome, that's wh

Re: simple prob?

2021-07-02 Thread Greg Wooledge
On Fri, Jul 02, 2021 at 09:09:34AM +0200, Phi Debian wrote: > PW$ function njobs > > { [ "$1" != "n" ] && typeset -n n="$1" > >typeset -a t ; readarray t <<<"$(jobs)" ;n=${#t[@]} > > } <<<$() is a poor imitation of < <() which is what you really want. readarray -t t < <(jobs); n=${#t[@]} Com

Re: simple prob?

2021-07-02 Thread Phi Debian
On Fri, Jul 2, 2021 at 11:15 AM Alex fxmbsw7 Ratchev wrote: > good debugging, yea i missed the n # count char, i type stupidly from a > cell foun, .. > and yea leftover arr ekements exceots when u just use the first one as n > i just wanted to show shorter code > Yes I like those little one line

Re: simple prob?

2021-07-02 Thread Alex fxmbsw7 Ratchev
good debugging, yea i missed the n # count char, i type stupidly from a cell foun, .. and yea leftover arr ekements exceots when u just use the first one as n i just wanted to show shorter code i also made somewhen a which_pid_exited resolver etc peace On Fri, Jul 2, 2021, 11:10 Phi Debian wrot

Re: simple prob?

2021-07-02 Thread Phi Debian
On Fri, Jul 2, 2021 at 9:24 AM Alex fxmbsw7 Ratchev wrote: > jobsn=( $( jobs -p ) ) jobsn=${jobsn[@]} > This give PW$ jobsn=( $( jobs -p ) ) jobsn=${jobsn[@]} PW$ echo $jobsn 3644 3645 3646 3647 I guess you meant jobsn=${#jobsn[@]} ^ You missed the

Re: simple prob?

2021-07-02 Thread Alex fxmbsw7 Ratchev
jobsn=( $( jobs -p ) ) jobsn=${jobsn[@]} On Fri, Jul 2, 2021, 09:10 Phi Debian wrote: > On Tue, Jun 29, 2021 at 10:23 PM L A Walsh wrote: > > > I hope a basic question isn't too offtopic. > > Say I have some number of jobs running: > > > > > jobs|wc -l > > 3 > > --- > > > > Would like to pass

Re: simple prob?

2021-07-02 Thread Phi Debian
On Tue, Jun 29, 2021 at 10:23 PM L A Walsh wrote: > I hope a basic question isn't too offtopic. > Say I have some number of jobs running: > > > jobs|wc -l > 3 > --- > > Would like to pass a varname to njobs to store the answer in, like: > > So I can run: > > > njobs n > echo "$n" > 3 > > This a