Skip to content

Commit

Permalink
Merge pull request #1328 from jonjohnsonjr/histfile-heredoc
Browse files Browse the repository at this point in the history
debug: Populate history file via mounts
  • Loading branch information
jonjohnsonjr authored Jun 26, 2024
2 parents df975c9 + ad2cd18 commit b967cbf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/build/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ func (r *pipelineRunner) maybeDebug(ctx context.Context, fragment string, cmd []
signal.Ignore(os.Interrupt)

// Populate ~/.ash_history with the current command so you can hit up arrow to repeat it.
history := fmt.Sprintf("echo '%s' >> ~/.ash_history", fragment)
if err := os.WriteFile(filepath.Join(r.config.WorkspaceDir, ".ash_history"), []byte(fragment), 0644); err != nil {
return fmt.Errorf("failed to write history file: %w", err)
}

if dbgErr := dbg.Debug(ctx, r.config, []string{"/bin/sh", "-c", fmt.Sprintf("%s && cd %s && exec /bin/sh", history, workdir)}...); dbgErr != nil {
if dbgErr := dbg.Debug(ctx, r.config, []string{"/bin/sh", "-c", fmt.Sprintf("cd %s && exec /bin/sh", workdir)}...); dbgErr != nil {
return fmt.Errorf("failed to debug: %w; original error: %w", dbgErr, runErr)
}

Expand Down

0 comments on commit b967cbf

Please sign in to comment.