lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


List,

 

I ran into some issues testing for os.execute() results. So I wrote some test code and executed it on Windows and Ubuntu 10. The code is run twice, once running os.execute, once with penlights execute method.

 

Test code: https://github.com/Tieske/exit_test/tree/f824170650139e906fbfb83febe311a1a87ef93c

 

The results (see below) are what I expected for Windows. But on Ubuntu, I can’t explain it.

The exitcodes are supposed to be between 0 and 255. So the os.exit(-5) and os.exit(400) are out of range, but the valid test; os.exit(25) also gives me a return value in os.execute() of 6400.

 

The windows one (further down below) just handles any numeric argument, also outside the 0-255 range.

 

Any clues to why this is happening?

Regards

Thijs

 

 

The Ubuntu output:

 

thijs@ubuntu:~/exit_test$ lua exit_test.lua

====> PLAIN <====

testing shell command (always success) (dir)

  #:1

  1:    0

testing non-existing command (always failure) (this_obviously_does_not_exist)

  #:1

  1:    32512

testing os.exit(25) exitcode (lua _exitcode.lua 25)

  #:1

  1:    6400

testing os.exit(-5) exitcode (lua _exitcode.lua -5)

  #:1

  1:    64256

testing os.exit(400) exitcode (lua _exitcode.lua 400)

 #:1

  1:    36864

testing erroneous script (lua _exiterror.lua)

  #:1

  1:    256

====> PENLIGHT <====

testing shell command (always success) (dir)

  #:2

  1:    true

 2:    0

testing non-existing command (always failure) (this_obviously_does_not_exist)

  #:2

  1:    false

  2:    32512

testing os.exit(25) exitcode (lua _exitcode.lua 25)

  #:2

  1:    false

  2:    6400

testing os.exit(-5) exitcode (lua _exitcode.lua -5)

  #:2

  1:    false

  2:    64256

testing os.exit(400) exitcode (lua _exitcode.lua 400)

  #:2

  1:    false

  2:    36864

testing erroneous script (lua _exiterror.lua)

  #:2

  1:    false

  2:    256

thijs@ubuntu:~/exit_test$

 

 

And on Windows:

 

C:\Users\Thijs\Dropbox\Lua projects\exit_test>exit_test.lua

====> PLAIN <====

testing shell command (always success) (dir)

  #:1

  1:    0

testing non-existing command (always failure) (this_obviously_does_not_exist)

  #:1

  1:    1

testing os.exit(25) exitcode (lua _exitcode.lua 25)

  #:1

  1:    25

testing os.exit(-5) exitcode (lua _exitcode.lua -5)

  #:1

  1:    -5

testing os.exit(400) exitcode (lua _exitcode.lua 400)

  #:1

  1:    400

testing erroneous script (lua _exiterror.lua)

  #:1

  1:    1

====> PENLIGHT <====

testing shell command (always success) (dir)

  #:2

  1:    true

  2:    0

testing non-existing command (always failure) (this_obviously_does_not_exist)

  #:2

  1:    false

  2:    1

testing os.exit(25) exitcode (lua _exitcode.lua 25)

  #:2

  1:    false

  2:    25

testing os.exit(-5) exitcode (lua _exitcode.lua -5)

  #:2

  1:    false

  2:    -5

testing os.exit(400) exitcode (lua _exitcode.lua 400)

  #:2

  1:    false

  2:    400

testing erroneous script (lua _exiterror.lua)

  #:2

  1:    false

  2:    1

 

C:\Users\Thijs\Dropbox\Lua projects\exit_test>