Skip to content

feat: Add ability to run commands at given path#536

Open
AtzeDeVries wants to merge 4 commits intomagefile:masterfrom
AtzeDeVries:add-at-to-sh
Open

feat: Add ability to run commands at given path#536
AtzeDeVries wants to merge 4 commits intomagefile:masterfrom
AtzeDeVries:add-at-to-sh

Conversation

@AtzeDeVries
Copy link

Sometimes a command needs to run at a given path. The current sh package does not have this ability. This PR adds the feature. It adds "At" to all the run functions where you can supply it with a path were it needs to run. The functions are added under a new name so this change is backwards compatable.

Sometimes a command needs to run at a given path. The current `sh`
package does not have this ability. This PR adds the feature. It adds
"At" to all the run functions where you can supply it with a path were
it needs to run. The functions are added under a new name so this change
is backwards compatable.

Signed-off-by: Atze de Vries <atze.wiebe.de.vries@coop.no>
Signed-off-by: Atze de Vries <atze.wiebe.de.vries@coop.no>
Copy link

@michel-laterman michel-laterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good.
I mostly have nitpicks

t.Errorf("expected ran to be true but was false.")
}
if out.String() != fmt.Sprintf("%s\n", pwd) {
t.Errorf("expected %s, got %q", fmt.Sprintf("%s\n", pwd), out)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is fmt.Sprintf("%s\n", pwd) used here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we are running the command "pwd" which should result in the correct pwd, which is set to be "/". So that is what we expect to get in return.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use t.Errorf("expected %s, got %q", pwd, out) or t.Errorf("expected %s\n, got %q", pwd, out) (if a newline is needed)?

t.Errorf("expected ran to be true but was false.")
}
if out.String() != fmt.Sprintf("%s\n", currentWd) {
t.Errorf("expected %s, got %q", fmt.Sprintf("%s\n", currentWd), out)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is fmt.Sprintf("%s\n", currentWd) used?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we run ExecAt with pwd "", we should test that this returns the actuall current path.

AtzeDeVries and others added 2 commits March 11, 2026 21:49
Co-authored-by: Michel Laterman <82832767+michel-laterman@users.noreply.github.com>
Signed-off-by: Atze de Vries <atze.wiebe.de.vries@coop.no>
@AtzeDeVries AtzeDeVries changed the title feat: Add ability to run commands at gives paths feat: Add ability to run commands at given path Mar 11, 2026
@AtzeDeVries
Copy link
Author

@natefinch Is this something you would like to have? If so, then i will keep the changes in sync with the current work you are doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants