forked from rubinius/rubinius
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Kernel.exec for 1.9 with environment variable as first argu…
…ment
- Loading branch information
1 parent
f1c7558
commit 6cc5a4f
Showing
5 changed files
with
66 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ range18.rbc | |
struct.rbc | ||
struct18.rbc | ||
process.rbc | ||
process18.rbc | ||
random.rbc | ||
regexp.rbc | ||
regexp18.rbc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Kernel | ||
def exec(cmd, *args) | ||
if args.empty? and cmd.kind_of? String | ||
raise Errno::ENOENT if cmd.empty? | ||
if /([*?{}\[\]<>()~&|$;'`"\n\s]|[^\w-])/o.match(cmd) | ||
Process.perform_exec "/bin/sh", ["sh", "-c", cmd] | ||
else | ||
Process.perform_exec cmd, [cmd] | ||
end | ||
else | ||
if cmd.kind_of? Array | ||
prog = cmd[0] | ||
name = cmd[1] | ||
else | ||
name = prog = cmd | ||
end | ||
|
||
argv = [name] | ||
args.each do |arg| | ||
argv << arg.to_s | ||
end | ||
|
||
Process.perform_exec prog, argv | ||
end | ||
end | ||
module_function :exec | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
fails:Kernel#exec passes environment vars to the child environment | ||
fails:Kernel#exec raises Errno::ENOENT if the script does not exist | ||
fails:Kernel#exec raises Errno::EACCES when the file does not have execute permissions | ||
fails:Kernel#exec raises Errno::ACCES when passed a directory |