Skip to content

Commit

Permalink
file add echo add -e param
Browse files Browse the repository at this point in the history
  • Loading branch information
binbin0325 committed Oct 27, 2022
1 parent 151f89d commit d13dff2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions exec/file/file_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (f *FileAddActionExecutor) Exec(uid string, ctx context.Context, model *spe
}

if exec.CheckFilepathExists(ctx, f.channel, filepath) {
log.Errorf(ctx,"`%s`: filepath is exist", filepath)
log.Errorf(ctx, "`%s`: filepath is exist", filepath)
return spec.ResponseFailWithFlags(spec.ParameterInvalid, "filepath", filepath, "the filepath is exist")
}

Expand All @@ -130,7 +130,7 @@ func (f *FileAddActionExecutor) Exec(uid string, ctx context.Context, model *spe
func (f *FileAddActionExecutor) start(cl spec.Channel, filepath, content string, directory, enableBase64, autoCreateDir bool, ctx context.Context) *spec.Response {

dir := path.Dir(filepath)
if autoCreateDir && ! exec.CheckFilepathExists(ctx, cl, filepath) {
if autoCreateDir && !exec.CheckFilepathExists(ctx, cl, filepath) {
if response := f.channel.Run(ctx, "mkdir", fmt.Sprintf(`-p %s`, dir)); !response.Success {
return response
}
Expand All @@ -149,7 +149,7 @@ func (f *FileAddActionExecutor) start(cl spec.Channel, filepath, content string,
content = string(decodeBytes)
}
}
return f.channel.Run(ctx, "echo", fmt.Sprintf(`"%s" >> "%s"`, content, filepath))
return f.channel.Run(ctx, "echo", fmt.Sprintf(`-e "%s" >> "%s"`, content, filepath))
}
}
}
Expand Down

0 comments on commit d13dff2

Please sign in to comment.