Consider executable extensions in case of some test commands on OS/2
-r, -w, -x, -a, -e, -f.
This commit is contained in:
parent
fdd0831a58
commit
a03cf65602
4
expr.c
4
expr.c
@ -906,12 +906,16 @@ int
|
||||
ksh_access(const char *fn, int mode)
|
||||
{
|
||||
int rv;
|
||||
#ifndef __OS2__
|
||||
struct stat sb;
|
||||
|
||||
if ((rv = access(fn, mode)) == 0 && kshuid == 0 && (mode & X_OK) &&
|
||||
(rv = stat(fn, &sb)) == 0 && !S_ISDIR(sb.st_mode) &&
|
||||
(sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0)
|
||||
rv = -1;
|
||||
#else
|
||||
rv = access_ex(access, fn, mode);
|
||||
#endif
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
16
funcs.c
16
funcs.c
@ -2943,6 +2943,14 @@ test_isop(Test_meta meta, const char *s)
|
||||
return (TO_NONOP);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
#define test_access(name, mode) access_ex(access, (name), (mode))
|
||||
#define test_stat(name, buffer) stat_ex((name), (buffer))
|
||||
#else
|
||||
#define test_access(name, mode) access((name), (mode))
|
||||
#define test_stat(name, buffer) stat((name), (buffer))
|
||||
#endif
|
||||
|
||||
int
|
||||
test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
|
||||
bool do_eval)
|
||||
@ -3008,12 +3016,12 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
|
||||
/* -r */
|
||||
case TO_FILRD:
|
||||
/* LINTED use of access */
|
||||
return (access(opnd1, R_OK) == 0);
|
||||
return (test_access(opnd1, R_OK) == 0);
|
||||
|
||||
/* -w */
|
||||
case TO_FILWR:
|
||||
/* LINTED use of access */
|
||||
return (access(opnd1, W_OK) == 0);
|
||||
return (test_access(opnd1, W_OK) == 0);
|
||||
|
||||
/* -x */
|
||||
case TO_FILEX:
|
||||
@ -3023,11 +3031,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
|
||||
case TO_FILAXST:
|
||||
/* -e */
|
||||
case TO_FILEXST:
|
||||
return (stat(opnd1, &b1) == 0);
|
||||
return (test_stat(opnd1, &b1) == 0);
|
||||
|
||||
/* -r */
|
||||
case TO_FILREG:
|
||||
return (stat(opnd1, &b1) == 0 && S_ISREG(b1.st_mode));
|
||||
return (test_stat(opnd1, &b1) == 0 && S_ISREG(b1.st_mode));
|
||||
|
||||
/* -d */
|
||||
case TO_FILID:
|
||||
|
7
os2.c
7
os2.c
@ -108,6 +108,13 @@ access_ex(int (*fn)(const char *, int), const char *name, int mode)
|
||||
return access_stat_ex(fn, name, (void *)mode);
|
||||
}
|
||||
|
||||
/* stat() version */
|
||||
int
|
||||
stat_ex(const char *name, struct stat *buffer)
|
||||
{
|
||||
return access_stat_ex(stat, name, buffer);
|
||||
}
|
||||
|
||||
static int
|
||||
test_exec_exist(const char *name, char *real_name)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user