mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
main.c: Tweak fixargs() (re: cefe087d
)
src/cmd/ksh93/sh/main.c: fixargs(): - Erase the entire length of the command arguments buffer (the space from argv[0] until environ[0]) so that remnants of longer command arguments aren't left in 'ps' output when executing a hashbang-ess script with a shorter command line. - Disable fixargs() on FreeBSD. It has never had any effect on that system; apparently it either requires another method to rewrite arguments for 'ps' output purposes (which?) or it's not possible. src/cmd/ksh93/tests/basic.sh: - Skip the test if running on FreeBSD.
This commit is contained in:
parent
e7202832fd
commit
159fb9ee27
2 changed files with 5 additions and 8 deletions
|
@ -52,7 +52,7 @@
|
|||
/* These routines are referenced by this module */
|
||||
static void exfile(Shell_t*, Sfio_t*,int);
|
||||
static void chkmail(Shell_t *shp, char*);
|
||||
#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
|
||||
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__)
|
||||
static void fixargs(char**,int);
|
||||
#else
|
||||
# define fixargs(a,b)
|
||||
|
@ -697,7 +697,7 @@ static void chkmail(Shell_t *shp, char *files)
|
|||
# define PSTAT 1
|
||||
#endif
|
||||
|
||||
#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
|
||||
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__FreeBSD__)
|
||||
/*
|
||||
* fix up command line for ps command
|
||||
*
|
||||
|
@ -735,9 +735,7 @@ static void fixargs(char **argv, int mode)
|
|||
if(mode==0)
|
||||
{
|
||||
buff = argv[0];
|
||||
while(cp = *argv++)
|
||||
command_len += strlen(cp)+1;
|
||||
command_len -= 1;
|
||||
command_len = environ[0] - buff - 1;
|
||||
return;
|
||||
}
|
||||
# endif /* PSTAT */
|
||||
|
|
|
@ -708,7 +708,8 @@ getPsOutput() {
|
|||
while [[ $actual == [[:space:]]* ]]; do actual=${actual#?}; done
|
||||
while [[ $actual == *[[:space:]] ]]; do actual=${actual%?}; done
|
||||
}
|
||||
if getPsOutput "$$"
|
||||
if [[ $(uname -s) != FreeBSD ]] &&
|
||||
getPsOutput "$$" &&
|
||||
[[ "$SHELL $0" == "$actual"* ]] # "$SHELL $0" is how shtests invokes this script
|
||||
then expect='./atest 1 2'
|
||||
echo 'sleep 10; exit 0' >atest
|
||||
|
@ -718,8 +719,6 @@ then expect='./atest 1 2'
|
|||
kill "$!"
|
||||
[[ $actual == "$expect" ]] || err_exit "ksh didn't rewrite argv correctly" \
|
||||
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||
else err_exit "warning: skipping argv rewrite test due to noncompliant 'ps' utility (got $(printf %q "$actual"))"
|
||||
let Errors--
|
||||
fi
|
||||
unset -f getPsOutput
|
||||
|
||||
|
|
Loading…
Reference in a new issue