- Timestamp:
- Jun 16, 2007, 11:37:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/essentials/app-shells/bash/execute_cmd.c
r3277 r3459 3701 3701 } 3702 3702 3703 #if !defined (HAVE_HASH_BANG_EXEC) 3703 #if !defined (HAVE_HASH_BANG_EXEC) || defined (__OS2__) /* OS2: see shell_execve. */ 3704 3704 /* If the operating system on which we're running does not handle 3705 3705 the #! executable format, then help out. SAMPLE is the text read … … 3757 3757 3758 3758 args[larry] = (char *)NULL; 3759 3760 #ifdef __OS2__ 3761 /* 3762 * We've got a relaxed attitued to #!/bin/something 3763 * since /bin usually is somewhere else. See __spawnve. 3764 */ 3765 { 3766 struct stat s; 3767 if (stat (execname, &s)) 3768 { 3769 char *tmp = _getname (execname); 3770 char *path = alloca (512); /* big buffer since the _searchenv interface is silly. */ 3771 _searchenv (execname, "PATH", path); 3772 if (!path[0]) 3773 { 3774 char *tmpbuf; 3775 size_t len = strlen (tmp); 3776 tmpbuf = alloca (len + 8); 3777 memcpy (tmpbuf, tmp, len + 1); 3778 _defext (tmpbuf, "exe"); 3779 if (tmpbuf[len]) 3780 _searchenv (tmpbuf, "PATH", path); 3781 } 3782 if (path[0]) 3783 execname = path; 3784 } 3785 } 3786 #endif 3759 3787 3760 3788 return (shell_execve (execname, args, env)); … … 3841 3869 char sample[80]; 3842 3870 int sample_len; 3871 3872 #ifdef __OS2__ 3873 /* 3874 * symlinked hash-bang scripts are currently broken, 3875 * this is an attemt at fixing some of the damage. 3876 */ 3877 static int been_here_already = 0; 3878 struct stat s; 3879 if (!lstat(command, &s) && S_ISLNK(s.st_mode) && been_here_already < 3) 3880 { 3881 READ_SAMPLE_BUF (command, sample, sample_len); 3882 if (sample_len > 2 && sample[0] == '#' && sample[1] == '!') 3883 { 3884 been_here_already++; 3885 return (execute_shell_script (sample, sample_len, command, args, env)); 3886 } 3887 } 3888 #endif 3843 3889 3844 3890 SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */
Note:
See TracChangeset
for help on using the changeset viewer.