Re: strange tcsh. vs. bash behavior of scp

From: Bill Unruh (unruh@physics.ubc.ca)
Date: 01/06/02


From: unruh@physics.ubc.ca (Bill Unruh)
Date: 6 Jan 2002 22:16:18 GMT

In <a16pe3$13nq$1@hedeland.org> per@bluetail.com (Per Hedeland) writes:

]In article <vXjZ7.14408$TM3.8759@nwrddc02.gnilink.net> "Nico
]Kadel-Garcia" <nkadel@bellatlantic.net> writes:
]>
]>"Richard E. Silverman" <slade@shore.net> wrote in message
]>news:m1l3d1mssyy.fsf@syrinx.oankali.net...
]>>
]>> > When I give the following command
]>> >
]>> > scp me@mymachine.univ.edu:file.* .
]>> >
]>> > from a tcsh I get the reply
]>> > "no match"
]>> >
]>> > But if I do the same thing from bash I get a proper
]>> > response (i.e. query for password, and downloading of
]>> > appropriate files).
]>>
]>> This has nothing to do wiht SSH; it is because of different quoting
]>> conventions between bash and tcsh. Bash does not happen to try to expand
]>> the glob because of the syntax, but tcsh does.

]Well, just to nitpick (and be off-topic:-), both shells try to expand
]the glob, but for a sh-type shell such as bash it is not an error for
]such an expansion to fail, it just leaves the pattern as-is, while for a
]csh-type shell such as tcsh, it is an error. You can make it not be an
]error in a csh-type shell by doing 'set nonomatch', but it may not be
]the generally desirable behaviour for interactive usage.

]Note the implication that in the (here unlikely, but still possible)
]case that the glob pattern *did* match one or more local files, either
]shell would do something totally different than what was intended - so
]quoting should always be used in a case like this.

]>> Simply enclose the first
]>> argument in single quotes; you want it to be expanded on the remote side,
]>> not here.
]>
]>Richard, oh ghod of SSH support, all blessings upon your head.
]>
]>Most of use this syntax instead:
]>
]> > scp me@mymachine.univ.edu:file.\* .
]>
]>I've found through bitter experience that keeping track of quotes can be a
]>horrid process, especially when you have things like shell scripts calling
]>perl scripts from inside Makefiles. It has been consistently much easier to
]>use backslashes, and just keep adding or deleting them as necessary.

]You didn't say of what population the most used that syntax:-), so I
]can't really comment on its accuracy, but I suspect that claim would be
]wrong for many populations - at least personally I basically never use
]backslash quoting, in interactive use or script writing, finding quotes
]to be far less cumbersome. YMMV, I guess.:-)

]--Per Hedeland
]per@bluetail.com

Remember that it is the local machine that expands the * in that line.
tcsh fines no files which start with file. and complains that there are
none. Bash by default tried to expand, but if there are none, it passes
on the literal *. But this is bad practice .
use the above suggestion or use
scp 'me@mymachine.univ.edu:file.*' .
instead so the * gets passed on to the other side.



Relevant Pages

  • Re: [SLE] Redirection puzzle
    ... What shell do you use for interactive shell sessions? ... "--norc" option in the script? ... I tried the tcsh counterpart: ... bash> tcsh ...
    (SuSE)
  • Re: bash & tcsh
    ... I use bash as the standard shell for all accounts on hp-ux, ... don't use tcsh. ... permissions to match the other system shells. ...
    (comp.sys.hp.hpux)
  • Re: strange tcsh. vs. bash behavior of scp
    ... >> conventions between bash and tcsh. ... csh-type shell such as tcsh, ... >perl scripts from inside Makefiles. ...
    (comp.security.ssh)
  • Re: Reliable shell logs
    ... bofh bash and tcsh are at ... > I tried google.com/bsd and found a bounch of sh patches, ... > And what stops the user from changing his shell? ... > would let him change shell to csh, tcsh or whatever is ...
    (FreeBSD-Security)
  • Re: Apparently, csh programming is considered harmful.
    ... tcsh as well. ... Standard shell for what? ... I used bash for an interactive shell for about 5 years until I ... I'm tempted to try doing the same on FreeBSD (replace sh with pdksh) ...
    (freebsd-questions)