zsh-workers
 help / color / mirror / code / Atom feed
* Strange behaviour in zsh-2.5.03
@ 1995-12-11  8:44 Sverre Slotte
  1995-12-11  9:08 ` Bas V. de Bakker
  1995-12-11  9:52 ` P.Stephenson
  0 siblings, 2 replies; 3+ messages in thread
From: Sverre Slotte @ 1995-12-11  8:44 UTC (permalink / raw)
  To: zsh-workers

Hi,

I'm running zsh version 2.5.03 on a Sun SparcStation 4 w/ Solaris 2.4.

I have a shell function called "lpr" that acts as a front-end to
/usr/ucb/lpr. It lets me specify the printer I want in a "localised"
fashion: -Pf and -Pc stand for fax-room printer and coffee-room
printer, respectively. Unfortunately, it fails in a mysterious manner.

The function looks like this:

    function lpr()
    {
        local printer=${PRINTER:-your_default_printer}
        local passthru=
    
        while [[ $# -gt 0 ]]
        do
            case "$1" in
                -Pc | -PC | -Pps3ac )
                    printer=ps3ac           # c for coffee-room
                    ;;
                -Pf | -PF | -Pps3d )
                    printer=ps3d            # f for fax-room
                    ;;
                -P )
                    $[2]=$1$2               # turn -P prn into -Pprn
                    ;;
                * )
                    passthru="$passthru $1"
                    ;;
            esac
            shift
        done
    
        command lpr -P${printer} ${passthru}    # this doesn't work!
    }

(Comments on shell-programming style welcome.)

The last line is the one that fails: if I try to print a file (e.g
lpr -Pc foobar.ps) I get the response "lpr: cannot access foobar.ps".

However, if I prepend the whole line with an echo, I get the expected
result on stdout: "command lpr -Pps3ac foobar.ps". And if I replace
the echo with eval, turning the line into

    eval command lpr -P${printer} ${passthru}

everything works fine: no complaints at all and foobar.ps appears on
the printer.

Any explanation for this? Is is a bug? Is it already fixed in
2.6.whatever?

Cheers,

Sverre

----------------------------------------------------------------------------
Sverre Slotte                            Internet: sverre@research.nokia.com
Nokia Research Center                    Phone:             + 358 0 43766208
P.O.Box 45, 00211 Helsingfors, Finland   Phax:              + 358 0 43766856
----------------------------------------------------------------------------
"Kajakken er uten sammenligning den ypperste enkeltmannsfarkost som finnes."
                                                      -- Fritjof Nansen 1891



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-12-11 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-12-11  8:44 Strange behaviour in zsh-2.5.03 Sverre Slotte
1995-12-11  9:08 ` Bas V. de Bakker
1995-12-11  9:52 ` P.Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).