1 /* os/2 compatibility functions -- follows Ruby's license */
15 chown(char *path
, int owner
, int group
)
22 link(char *from
, char *to
)
28 #if defined(EMX_REPLACE_GETCWD) && (EMX_REPLACE_GETCWD) \
29 || defined(EMX_REPLACE_CHDIR) && (EMX_REPLACE_CHDIR)
32 #if defined(EMX_REPLACE_GETCWD) && (EMX_REPLACE_GETCWD)
33 /* to handle the drive letter and DBCS characters within a given path */
35 getcwd(char *path
, size_t len
)
37 return _getcwd2(path
, (int)len
);
41 #if defined(EMX_REPLACE_CHDIR) && (EMX_REPLACE_CHDIR)
42 /* to handle the drive letter and DBCS characters within a given path */
44 chdir(__const__
char *path
)
60 char *shell
, *sw
, *cmd2
;
63 if ((shell
= getenv("RUBYSHELL")) != NULL
&& *shell
!= '\0') {
66 *s
= isupper(*s
) ? tolower(*s
) : *s
;
68 if (strstr(shell
, "cmd") || strstr(shell
, "4os2"))
72 } else if ((shell
= getenv("SHELL")) != NULL
&& *shell
!= '\0') {
75 *s
= isupper(*s
) ? tolower(*s
) : *s
;
77 if (strstr(shell
, "cmd") || strstr(shell
, "4os2"))
81 } else if ((shell
= getenv("COMSPEC")) != NULL
&& *shell
!= '\0') {
84 *s
= isupper(*s
) ? tolower(*s
) : *s
;
86 if (strstr(shell
, "cmd") || strstr(shell
, "4os2"))
91 /* see if there are shell metacharacters in it */
93 /* for (s = cmd; *s && isalpha(*s); s++) ;
96 for (s
= cmd
; *s
; s
++) {
97 if (*sw
== '-' && *s
!= ' ' &&
98 !isalpha(*s
) && index("$&*(){}[]'\";\\|?<>~`\n",*s
)) {
99 if (*s
== '\n' && !s
[1]) {
104 } else if (*sw
== '/' && *s
!= ' ' &&
105 !isalpha(*s
) && index("^()<>|&\n",*s
)) {
106 if (*s
== '\n' && !s
[1]) {
111 status
= spawnlp(P_WAIT
,shell
,shell
,sw
,cmd
,(char*)NULL
);
115 argv
= ALLOC_N(CHARP
,(strlen(cmd
) / 2 + 2));
116 cmd2
= ALLOC_N(char, (strlen(cmd
) + 1));
119 for (s
= cmd2
; *s
;) {
120 while (*s
&& isspace(*s
)) s
++;
123 while (*s
&& !isspace(*s
)) s
++;
129 if ((status
= spawnvp(P_WAIT
, argv
[0], argv
)) == -1) {