help-bash
[Top][All Lists]
Advanced

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

Re: Passing list of filename suffixes to script.


From: Alex fxmbsw7 Ratchev
Subject: Re: Passing list of filename suffixes to script.
Date: Sat, 24 Jul 2021 18:52:14 +0200

i made a script like always for it, but to my surprise it doesnt work

./*.xz
is there, but it doesnt return anything
from three @(..) extglobs
@(./)@(*.)@(xz|other)

is this a lack of glob inside @( ?

without args my script behaves like ./ and *
out of three possibilities, pre mid and stu, separated by -- arg

bash -x pattern2 ./ -- '*.' -- xz bin

#!/bin/bash

shopt -s extglob dotglob globstar nullglob

mode=0 IFS=\|
for arg ; do
 [[ $arg == -- ]] && {
  (( mode++ ))
  continue
 }
 declare -a "mode_$mode+=( ${arg@Q} )"
done

mklist() {
 declare -g "$1=@(${*:2})"
}

mklist pre "${mode_0[@]:-./}"
mklist mid "${mode_1[@]:-*}"
mklist stu "${mode_2[@]}"

#printf '%s\n' "$pre$mid$stu"
printf '%s\n' $pre$mid$stu
#eval "printf '%s\n' $pre$mid$stu"

On Sat, Jul 24, 2021 at 6:29 PM <dora-solomon@brusseler.com> wrote:
>
>
> I want to pass a list of filename suffixes to a bash script.  Need also to 
> accept CVS with filename
>
> suffixes ,v and the usual period (dot) suffixes ( e.g. .c .f ).  But perhaps 
> there are other filename
>
> suffixes to accept, or else accept any pattern.
>
>



reply via email to

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