lua-users home
lua-l archive

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


> This:

>  os.execute("test -e '" .. PATH .. "'")
>  io.stdout:write("--> Setting permissions...\n")

> can be rewritten as

>  exec "test -e $PATH"
>  echo "--> Setting permissions...\n"

> under suitable definition of `exec` and `echo` (with caveats on
> StringInterpolation mentioned in my last post).

Looks nice, thanks.

How to rewrite error handling?

    os.execute(
        "cd '" .. PATH .. "'"
     .. " && git init --bare --shared"
     .. " && cd - >/dev/null"
      ) ~= 0

Exec probably should return true when launched command returns 0 and
nil, status-code when it is non-zero:

    (exec "cd $PATH") and (exec "git init --bare --shared") and (exec
"cd - >/dev/null")

What to do with output redirection and piping?

Should it be left to the shell?

    exec "cd - >/dev/null"
    exec "cat filename | bzip2 > filename.bz2"

Or should we support some fancier syntax at Lua side?

Any other ideas how should it look like?

Alexander.