From: Matt Watson <mwatson@apple.com>
To: zsh-workers@sunsite.auc.dk
Subject: zsh appears to be eating characters when called with -c
Date: Wed, 21 Feb 2001 17:58:12 -0800 [thread overview]
Message-ID: <200102220158.RAA08813@scv1.apple.com> (raw)
Can anyone explain what's going on here? I have a file with a UTF-8
name, yet zsh seems to be munging the input when I pass this file name
on the command line. We link /bin/sh to /bin/zsh. Here's a diagnosis
from our bug database:
bash-2.03$ /bin/tcsh -c 'echo NTT-ME\
MN128\343\202\267\343\203\252\343\203\274\343\202\271\343\202\231\ 128K\
ARA' | od -x
0000000 4e54 542d 4d45 204d 4e31 3238 e382 b7e3
0000020 83aa e383 bce3 82b9 e382 9920 3132 384b
0000040 2041 5241 0a00
0000045
bash-2.03$ /usr/local/bin/bash -c 'echo NTT-ME\
MN128\343\202\267\343\203\252\343\203\274\343\202\271\343\202\231\ 128K\
ARA' | od -x
0000000 4e54 542d 4d45 204d 4e31 3238 e382 b7e3
0000020 83aa e383 bce3 82b9 e382 9920 3132 384b
0000040 2041 5241 0a00
0000045
/bin/sh is zsh
bash-2.03$ /bin/sh -c 'echo NTT-ME\
MN128\343\202\267\343\203\252\343\203\274\343\202\271\343\202\231\ 128K\
ARA' | od -x
0000000 4e54 542d 4d45 204d 4e31 3238 e382 b7e3
0000020 8ae3 9ce3 82b9 e382 2031 3238 4b20 4152
0000040 410a
0000042
the actual file name is :
NTT-ME\
MN128\343\202\267\343\203\252\343\203\274\343\202\271\343\202\231\ 128K\
ARA
It seems that zsh is interpreting some of the bytes (removing some,
replacing others), while tcsh and bash just work as expected.
ppp executes a command with parameters using /bin/sh, and will fail when
the parameters contain this kind of file names (japanese modem scripts).
As a work around, ppp can use /bin/tcsh.
But is zsh supposed to interpret bytes in single quotes ?
Try this (no use of echo this time):
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
void testshell(const char *shell, const char *command)
{
int status = 0;
int r = fork();
switch (r) {
case -1:
fprintf(stderr, "fork() failed: %s\n", strerror(errno));
break;
case 0:
fprintf(stdout, "%s: ", shell);
fflush(stdout);
execlp(shell, shell, "-c", command, NULL);
fprintf(stderr, "execlp() failed: %s\n",
strerror(errno));
break;
default:
waitpid(r, &status, 0);
break;
}
}
int main(void)
{
char file[] = { 'N', 'T', 'T', '-', 'M', 'E', ' ', 'M',
'N', '1', '2', '8', 0343, 0202, 0267, 0343,
0203, 0252, 0343, 0203, 0274, 0343, 0202, 0271,
0343, 0202, 0231, ' ', '1', '2', '8', 'K',
' ', 'A', 'R', 'A', 0 };
char tmpfile[256] = "/tmp/";
char cmd[256] = "cat ";
FILE *tmpf;
strcat(tmpfile, file);
tmpf = fopen(tmpfile, "w");
if (tmpf == NULL) {
fprintf(stderr, "failed to open: %s\n", tmpfile);
exit(1);
}
fprintf(tmpf, "Hello World!\n");
fclose(tmpf);
strcat(cmd, "'");
strcat(cmd, tmpfile);
strcat(cmd, "'");
testshell("/usr/local/bin/bash", cmd);
testshell("/bin/tcsh", cmd);
testshell("/bin/zsh", cmd);
testshell("/bin/sh", cmd);
exit(0);
}
next reply other threads:[~2001-02-22 1:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-22 1:58 Matt Watson [this message]
2001-02-22 2:23 Matt Watson
2001-02-22 4:21 Matt Watson
2001-02-22 8:20 Sven Wischnowsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200102220158.RAA08813@scv1.apple.com \
--to=mwatson@apple.com \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).