Skip to content

Commit

Permalink
add no-tty flag to exec command
Browse files Browse the repository at this point in the history
  • Loading branch information
MadridianFox committed Sep 1, 2022
1 parent 10b3762 commit 5abe492
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/elc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func parseStartFlags(cmd *cobra.Command) {

func parseExecFlags(cmd *cobra.Command) {
cmd.Flags().IntVar(&globalOptions.UID, "uid", -1, "use another uid, by default uses uid of current user")
cmd.Flags().BoolVar(&globalOptions.NoTty, "no-tty", false, "disable pseudo-TTY allocation")
}

func InitCobra() *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion core/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (comp *Component) Exec(options *GlobalOptions) (int, error) {
command = append(command, "-u", fmt.Sprintf("%s:%s", userId, groupId))
}

if !Pc.IsTerminal() {
if options.NoTty || !Pc.IsTerminal() {
command = append(command, "-T")
}
command = append(command, "app")
Expand Down
3 changes: 2 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type GlobalOptions struct {
UID int
Tag string
DryRun bool
NoTty bool
}

func contains(list []string, item string) bool {
Expand Down Expand Up @@ -94,7 +95,7 @@ func GenerateHookScript(scripts []string, elcBinary string) string {
result = append(result, "set -e")
result = append(result, `printf "\x1b[0;34m%s\x1b[39;49;00m\n" "Run hook in ELC"`)
for _, script := range scripts {
result = append(result, fmt.Sprintf("%s --mode=hook %s", elcBinary, script))
result = append(result, fmt.Sprintf("%s --mode=hook --no-tty %s", elcBinary, script))
}

return strings.Join(result, "\n")
Expand Down

0 comments on commit 5abe492

Please sign in to comment.