[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: code not working ..
From: |
alex xmb sw ratchev |
Subject: |
Re: code not working .. |
Date: |
Wed, 11 Sep 2024 01:43:53 +0200 |
On Wed, Sep 11, 2024, 1:41 AM alex xmb sw ratchev <fxmbsw7@gmail.com> wrote:
>
>
> On Wed, Sep 11, 2024, 1:39 AM alex xmb sw ratchev <fxmbsw7@gmail.com>
> wrote:
>
>>
>>
>> On Wed, Sep 11, 2024, 1:35 AM alex xmb sw ratchev <fxmbsw7@gmail.com>
>> wrote:
>>
>>>
>>>
>>> On Wed, Sep 11, 2024, 1:14 AM Greg Wooledge <greg@wooledge.org> wrote:
>>>
>>>> On Wed, Sep 11, 2024 at 00:25:15 +0200, alex xmb sw ratchev wrote:
>>>> > i got in a script
>>>> >
>>>> > ca=( "$@" )
>>>> > checkarg() {
>>>> !
>>>> > (( $# )) &&
>>>> > return 1
>>>> > local IFS=$'\xff \t\n' i a
>>>> > i=${IFS:0:1}
>>>> > for a ; do
>>>> > [[ ${ca[*]//"$i"/'^^'} == @(#|"$i")@("$a")@(%|"$i") ]] ||
>>>> > return 1
>>>> > done
>>>> > return 0
>>>> > }
>>>>
>>>
>> the solution is
>> [[ $i$ca$i == $i$a$i ]]
>> i think
>> .. thanks and greets ..
>>
>
> i mean
> [[ $i${ca//$i/other}$i == *"$i$a$i"* ]]
>
worked perfectly
greets ..
> checkarg 1 &&
>>>> > exit
>>>>
>>>> This function should return 1 immediately if you give it any arguments.
>>>> The function you pasted into this email is not the same one you're
>>>> running.
>>>>
>>>
>>> gmail client stripped the ! sign away it seems to me
>>> i send full script
>>>
>>> > -- the script runs , but at checkarg 1 ( 1 is first and only arg to
>>>> script
>>>> > ) fails at the [[ , not returning 0
>>>> >
>>>> > -x says
>>>> >
>>>> > + ca=("$@")
>>>> > + checkarg 1
>>>> > + (( 1 ))
>>>> > + local 'IFS=�
>>>> > ' i a
>>>> > + i=$'\377'
>>>> > + for a in "$@"
>>>> > + [[ 1 == @(#|\�)@(\1)@(%|\�) ]]
>>>> > + return 1
>>>> >
>>>> > but why doesnt it return null ?
>>>>
>>>> Assuming that the function you executed actually has
>>>>
>>>> (( $# )) || return 1
>>>>
>>>> instead of
>>>>
>>>> (( $# )) && return 1
>>>>
>>>
>>> sorry just gmail version .. code goes ! (( ..
>>> btw at -x u'd see the [[ gets run
>>> eg it didnt return 1 on $?
>>>
>>> you are trying to match the string "1" against a pattern whose first
>>>> character must be "#" or $'\xff', and "1" is not either of these. So
>>>> it doesn't match the pattern.
>>>>
>>>
>>> i thought in extglob there is # and %
>>> after thinking long i think i got the solution
>>> hmm nah i didnt get it
>>>
>>> What happens from there is anyone's guess, because you aren't showing
>>>> us the right function.
>>>>
>>>
>>> its actual code and -x from it
>>> just weird the ! sign went away
>>>
>>> > its supposed to do : ( argslist , with arg '1' as check )
>>>> > args list , flat , xff separator , with inside occurrence of xff
>>>> > ==
>>>> > @(either beginning of whole || or xff )
>>>>
>>>> Why do you believe that the "#" character is "beginning of whole"?
>>>> It's not.
>>>>
>>>> Glob patterns are always anchored, similar to a regex with ^ at the
>>>> start and $ at the end. You don't need to put # in to serve as an
>>>> anchor. If you put # there, it's just a plain, literal character
>>>> that has to be matched.
>>>>
>>>
>>> hmm hard to code an args check like this ..
>>>
>>> > is xff 377 ?
>>>>
>>>> \xff is \0377. They are both encodings of a byte where every bit is 1.
>>>>
>>>>
- code not working .., alex xmb sw ratchev, 2024/09/10
- Re: code not working .., Greg Wooledge, 2024/09/10
- Re: code not working .., Greg Wooledge, 2024/09/10
- Re: code not working .., alex xmb sw ratchev, 2024/09/10
- Re: code not working .., Greg Wooledge, 2024/09/10
- Re: code not working .., alex xmb sw ratchev, 2024/09/11