Merge remote-tracking branch 'origin/master' into wip
[src/xds/xds-server.git] / lib / apiv1 / exec.go
index 0167196..30444c1 100644 (file)
@@ -105,15 +105,19 @@ func (s *APIService) execCmd(c *gin.Context) {
        }
 
        // Allow to pass id in url (/exec/:id) or as JSON argument
-       id := c.Param("id")
-       if id == "" {
-               id = args.ID
+       idArg := c.Param("id")
+       if idArg == "" {
+               idArg = args.ID
        }
-       if id == "" {
+       if idArg == "" {
                common.APIError(c, "Invalid id")
                return
        }
-
+       id, err := s.mfolders.ResolveID(idArg)
+       if err != nil {
+               common.APIError(c, err.Error())
+               return
+       }
        f := s.mfolders.Get(id)
        if f == nil {
                common.APIError(c, "Unknown id")
@@ -136,7 +140,7 @@ func (s *APIService) execCmd(c *gin.Context) {
                }
        }
 
-       cmd = append(cmd, "cd", fld.GetFullPath(args.RPath))
+       cmd = append(cmd, "cd", "\""+fld.GetFullPath(args.RPath)+"\"")
        // FIXME - add 'exec' prevents to use syntax:
        //       xds-exec -l debug -c xds-config.env -- "cd build && cmake .."
        //  but exec is mandatory to allow to pass correctly signals