help-bash
[Top][All Lists]
Advanced

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

Re: non working code .. loop ends after one


From: alex xmb ratchev
Subject: Re: non working code .. loop ends after one
Date: Thu, 2 Mar 2023 00:23:19 +0100

On Thu, Mar 2, 2023, 12:20 AM alex xmb ratchev <fxmbsw7@gmail.com> wrote:

>
>
> On Thu, Mar 2, 2023, 12:07 AM alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>
>>
>>
>> On Wed, Mar 1, 2023, 11:23 PM Kerin Millar <kfm@plushkava.net> wrote:
>>
>>> On Wed, 1 Mar 2023 22:11:35 +0100
>>> alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>>>
>>> > hello ,
>>> > im at a scp file list script
>>> > it had few typos , then it began to work
>>> > but only one line outta the file
>>> > then nothing , just exit ..
>>> >
>>> >  the cmd is
>>> > bash -x scp.u shone {user}@192.168.106.97:/mnt/1/fav aa1
>>> >
>>> > shone the ' ssh hash one dir '
>>> > aa1 is a \0 sep file list
>>>
>>> Are you sure?
>>>
>>
>> file list is normalo , in less -RU the \0 show as ^@ , also in terminal
>> IFS= read .. loop it works
>>
>> In any case, the code is odd. sep=${sep:-\\0} assigns '\0' if otherwise
>>> undefined. [[ $sep == *\\* ]] && declare -a "sep=$( $'sep' )" will then
>>> make sep an array (why?) whose first element is an empty string. It is
>>> unnecessarily complicated and error-prone. Just let sep _be_ the empty
>>> string to begin with, if you expect records ending with NUL.
>>>
>>
>> its expected , ..
>> i tried make \0 or \n ( or other accessable )
>> the bash read -d way is '' for 0 and <real n> for n
>>
>> bash read -d sep 'one_char( or more i dunno )'
>> in awk it doesnt matter
>> user enters ( or by default ) \0 it needs to expand , bash read '' but uh
>> for awk i think i got a workaround there ..
>> .. i just looked , awk is elsewhere , i had an other version in mind ..
>>
>> i used declare [-a] "<definition>' to make bash parse the \<code>
>>
>> ( $sep is _needed_ to be empty , for bash \0 case , its .. empty .. read
>> -rd "$empty" )
>>
>> Despite this, it doesn't do the wrong thing in the case that sep begins
>>> by being unset/empty.
>>>
>>
>> despire i didnt awk ..
>> say a user wants to enter \0 or \n
>> the literal string
>> i use this declare to make it "$read_d_value"
>>
>> $ unset -v sep; sep=${sep:-\\0}; [[ $sep == *\\* ]] && declare -a "sep=(
>>> $'$sep' )"
>>> $ declare -p sep
>>> declare -a sep=([0]="")
>>> $ printf '%s\0' foo bar | { IFS= read -rd "$sep" x; IFS= read -rd "$sep"
>>> y; declare -p x y; }
>>> declare -- x="foo"
>>> declare -- y="bar"
>>>
>>> This works because "$sep" == "${sep[0]}" == "". If you were to produce a
>>> smaller test case that someone else can easily run, it could help to get to
>>> the bottom of it.
>>>
>>
>> about a test case , i cant from scratch bughunt , like script new
>> but it should be simple a one cmd for my script ..
>>
>> done .. in my tests to localhost scp said connection closed , was with
>> localhost and port 1112 ( andro deb proot )
>> i did add rest code to support port= passing
>> changed to laptop ip and port 22 ..
>> .. does same error , one file , then no more
>>
>
> in short thats the case , i second last line
> done <"$df" ( datafile ) or $fl filelist
> last line done outer loop
> then the story is that < $df works 1once , then it exits ( by read failing
> maybe )
> or , when hash of first file is existing ( == file sent complete ) , it
> doesnt go past .. exit
>

with ' file sent complete ' i mean
' file was already sent marked '

set -x ; t=/tmp/testssh/ o=$t/out/ i=$t/in/ h=$t/hash/ port=22 ; rm -rf
>> "$t" ; mkdir -p "$t"{,in,out,hash} ; seq 3 >"$o/1" ; seq 5 7 >"$o/2" ; seq
>> 100 77 >"$o/3" ; port=$port pf="$o" bash -x scp.u "$h/first"
>> ye@192.168.247.97:"$i" <( find "$o" -depth -type f -print0 )
>>
>> --
>>> Kerin Millar
>>>
>>


reply via email to

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