projects
/
mmh
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed ; to && in shell command, per Ralph's suggestion. There
[mmh]
/
uip
/
whatnowsbr.c
diff --git
a/uip/whatnowsbr.c
b/uip/whatnowsbr.c
index
1d21bd3
..
4aaf921
100644
(file)
--- a/
uip/whatnowsbr.c
+++ b/
uip/whatnowsbr.c
@@
-97,7
+97,7
@@
static struct swit aleqs[] = {
#define PWDCMDSW 11
{ "pwd", 0 },
#define LSCMDSW 12
#define PWDCMDSW 11
{ "pwd", 0 },
#define LSCMDSW 12
- { "ls", 0 },
+ { "ls", 2 },
#define ATTACHCMDSW 13
{ "attach", 0 },
#define DETACHCMDSW 14
#define ATTACHCMDSW 13
{ "attach", 0 },
#define DETACHCMDSW 14
@@
-336,7
+336,7
@@
WhatNow (int argc, char **argv)
*/
if (*(argp+1) == (char *)0) {
*/
if (*(argp+1) == (char *)0) {
- (void)sprintf(buf, "$SHELL -c \"cd;pwd\"");
+ (void)sprintf(buf, "$SHELL -c \"cd&&pwd\"");
}
else {
writesomecmd(buf, BUFSIZ, "cd", "pwd", argp);
}
else {
writesomecmd(buf, BUFSIZ, "cd", "pwd", argp);
@@
-561,9
+561,9
@@
writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
* new C99 mandated 'number of chars that would have been written'
*/
/* length checks here and inside the loop allow for the
* new C99 mandated 'number of chars that would have been written'
*/
/* length checks here and inside the loop allow for the
- * trailing ';', trailcmd, '"' and NUL
+ * trailing "&&", trailcmd, '"' and NUL
*/
*/
- int trailln = strlen(trailcmd) + 3;
+ int trailln = strlen(trailcmd) + 4;
if (ln < 0 || ln + trailln > bufsz)
adios((char *)0, "arguments too long");
if (ln < 0 || ln + trailln > bufsz)
adios((char *)0, "arguments too long");
@@
-579,9
+579,9
@@
writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp)
cp += ln;
}
if (*trailcmd) {
cp += ln;
}
if (*trailcmd) {
- *cp++ = ';';
+ *cp++ = '&'; *cp++ = '&';
strcpy(cp, trailcmd);
strcpy(cp, trailcmd);
- cp += trailln - 3;
+ cp += trailln - 4;
}
*cp++ = '"';
*cp = 0;
}
*cp++ = '"';
*cp = 0;
@@
-605,6
+605,11
@@
system_in_dir(const char *dir, const char *cmd)
{
char olddir[BUFSIZ];
int r;
{
char olddir[BUFSIZ];
int r;
+
+ /* ensure that $SHELL exists, as the cmd was written relying on
+ a non-blank $SHELL... */
+ setenv("SHELL","/bin/sh",0); /* don't overwrite */
+
if (getcwd(olddir, sizeof(olddir)) == 0)
adios("getcwd", "could not get working directory");
if (chdir(dir) != 0)
if (getcwd(olddir, sizeof(olddir)) == 0)
adios("getcwd", "could not get working directory");
if (chdir(dir) != 0)
@@
-621,6
+626,11
@@
popen_in_dir(const char *dir, const char *cmd, const char *type)
{
char olddir[BUFSIZ];
FILE *f;
{
char olddir[BUFSIZ];
FILE *f;
+
+ /* ensure that $SHELL exists, as the cmd was written relying on
+ a non-blank $SHELL... */
+ setenv("SHELL","/bin/sh",0); /* don't overwrite */
+
if (getcwd(olddir, sizeof(olddir)) == 0)
adios("getcwd", "could not get working directory");
if (chdir(dir) != 0)
if (getcwd(olddir, sizeof(olddir)) == 0)
adios("getcwd", "could not get working directory");
if (chdir(dir) != 0)