perform arg type checking and evaluation before function call
This commit is contained in:
parent
90284f2d06
commit
ab340ceb0a
9 changed files with 223 additions and 354 deletions
|
|
@ -225,11 +225,6 @@ func LaunchProcess(
|
|||
* Example (l vim file.txt)
|
||||
*/
|
||||
func Call(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
in = in.Eval(ft, vt, true)
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if in.Tag == ast.LIST {
|
||||
log.Log(log.ERR, "couldnt exec, target bin is a list", "call")
|
||||
return nil
|
||||
|
|
@ -261,11 +256,6 @@ func Call(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
* Example: (bg vim file.txt)
|
||||
*/
|
||||
func Bgcall(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
in = in.Eval(ft, vt, true)
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if in.Tag == ast.LIST {
|
||||
log.Log(log.ERR, "couldnt exec, target bin is a list", "call")
|
||||
return nil
|
||||
|
|
@ -304,14 +294,6 @@ func Fg(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
return nil
|
||||
}
|
||||
|
||||
in = in.Eval(ft, vt, false)
|
||||
if in.Tag != ast.NUMBER && in.Tag != ast.STRING {
|
||||
log.Log(log.ERR,
|
||||
"must supply a number or string to fg",
|
||||
"fg")
|
||||
return nil
|
||||
}
|
||||
|
||||
pid, err := strconv.ParseFloat(in.Value(), 64)
|
||||
if err != nil {
|
||||
log.Log(log.ERR,
|
||||
|
|
@ -374,12 +356,6 @@ func Jobs(in *ast.Token, vt ast.VarTable, fg ast.FuncTable) *ast.Token {
|
|||
* Example: ($ echo hello world)
|
||||
*/
|
||||
func ReadCmd(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
in = in.Eval(ft, vt, true)
|
||||
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if in.Tag == ast.LIST {
|
||||
log.Log(log.ERR, "couldnt exec, target bin is a list", "call")
|
||||
return nil
|
||||
|
|
@ -434,13 +410,6 @@ func GetExit(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
* (this function not added to functable in stdlib.go)
|
||||
*/
|
||||
func Kill(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
in = in.Eval(ft, vt, true)
|
||||
|
||||
if in.Tag == ast.LIST {
|
||||
log.Log(log.ERR, "non-number argument to kill function", "kill")
|
||||
return nil
|
||||
}
|
||||
|
||||
pid, err := strconv.ParseInt(in.Value(), 10, 64)
|
||||
if err != nil {
|
||||
log.Log(log.ERR, "error parsing arg to kill: " + err.Error(), "kill")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue