Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

stdios confused by a function scope ?



hello zsh people,

Here is a tmux capture i want to share with you as it completly got me
lost. it seems that a command which works well directly from the
interactive shell is loosing stdin when it is called from a function.

I have no time to investigate for now (and yet, a work around was written and the rt 
function is a fake that just show what is failing) but i really would like to
understand what happened.  

any clue (or ideas for me to investigate) is welcome. 

regards

#### Chapter 1: What we have 

>  print $ZSH_VERSION; which n2/ls n2/asqueue rt fill n2/tk/running
5.0.2
n2/ls () {
        rt ls -s -o Created -q masters "$(  n2/tk/running owner=Nobody )" | n2/asqueue
}
n2/asqueue () {
        sed '1{/^No/Q};s/:/ #/'
}
rt () {
        (
                export RTUSER RTPASSWD RTSERVER RTDEBUG
                 < ~/.uds/rt/credentials | fill RTUSER RTPASSWD RTSERVER
                echo "$@"
        )
}
fill () {
        local garbage
        IFS=$'\n' read -d '' "$@" garbage
}
n2/tk/running () {
        print -f '%s
        and status!=resolved
        and status!=rejected
        and status!=stalled
    ' "$@"
}

#### Chapter 2: the body of n2/ls works fine

> rt ls -s -o Created -q masters "$(  n2/tk/running owner=Nobody )" | n2/asqueue
ls -s -o Created -q masters owner=Nobody
        and status!=resolved
        and status!=rejected
        and status!=stalled

#### Chapter 3: n2/ls is a never ending story

> set -x
> n2/ls
+-zsh:6> n2/ls
+n2/ls:1> n2/tk/running 'owner=Nobody'
+n2/tk/running:1> print -f '%s
        and status!=resolved
        and status!=rejected
        and status!=stalled
    ' 'owner=Nobody'
+n2/ls:3> n2/asqueue
+n2/ls:1> rt ls -s -o Created -q masters 'owner=Nobody
        and status!=resolved
        and status!=rejected
+n2/asqueue:0> sed '1{/^No/Q};s/:/ #/'
        and status!=stalled
    '
+rt:8> export RTUSER RTPASSWD RTSERVER RTDEBUG
+rt:9> fill RTUSER RTPASSWD RTSERVER
+fill:0> local garbage
+fill:0> IFS='
' +fill:0> read -d '' RTUSER RTPASSWD RTSERVER garbage

-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
    -- Abraham Lincoln



Messages sorted by: Reverse Date, Date, Thread, Author