Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/commands/alias/alias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ describe("alias command", () => {
});
});

describe("alias expansion with tilde", () => {
it("preserves ~/ in alias arguments", async () => {
const bash = new Bash({
env: { HOME: "/home/user", BASH_ALIAS_ll: "ls -alF" },
});
await bash.exec("shopt -s expand_aliases");
const direct = await bash.exec("ls -alF ~/");
const aliased = await bash.exec("ll ~/");
expect(aliased.stdout).toBe(direct.stdout);
expect(aliased.stderr).toBe(direct.stderr);
});
});

// Note: Alias expansion is NOT implemented to match real bash behavior.
// In non-interactive mode (scripts), bash does not expand aliases.
// The alias command only stores/lists alias definitions.
Expand Down
4 changes: 4 additions & 0 deletions src/interpreter/alias-expansion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ function wordNodeToString(word: WordNode): string {
case "Glob":
result += part.pattern;
break;
case "TildeExpansion":
result += "~";
if (part.user) result += part.user;
break;
default:
// For other types, try to preserve as-is
break;
Expand Down