mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
Shell: Fixed pushd
and popd
Fixed a few issues with both `pushd` and `popd`. There was a few typos etcetera causing it to behave errantly in certain situations.
This commit is contained in:
parent
77d6dbc236
commit
2976e889e9
1 changed files with 6 additions and 5 deletions
|
@ -175,7 +175,7 @@ static int sh_popd(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
const char* arg = argv[i];
|
const char* arg = argv[i];
|
||||||
if (!strcmp(arg, "-n")) {
|
if (!strcmp(arg, "-n")) {
|
||||||
should_switch = false;
|
should_switch = false;
|
||||||
|
@ -189,7 +189,6 @@ static int sh_popd(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* real_path = canonical_path.string().characters();
|
const char* real_path = canonical_path.string().characters();
|
||||||
g.directory_stack.append(g.cwd.characters());
|
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int rc = stat(real_path, &st);
|
int rc = stat(real_path, &st);
|
||||||
|
@ -247,13 +246,16 @@ static int sh_pushd(int argc, char** argv)
|
||||||
|
|
||||||
// Let's assume the user's typed in 'pushd <dir>'
|
// Let's assume the user's typed in 'pushd <dir>'
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
|
g.directory_stack.append(g.cwd.characters());
|
||||||
if (argv[1][0] == '/') {
|
if (argv[1][0] == '/') {
|
||||||
path_builder.append(argv[1]);
|
path_builder.append(argv[1]);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
path_builder.appendf("%s/%s", g.cwd.characters(), argv[1]);
|
path_builder.appendf("%s/%s", g.cwd.characters(), argv[1]);
|
||||||
|
}
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
for (int i = 0; i < argc; i++) {
|
g.directory_stack.append(g.cwd.characters());
|
||||||
|
for (int i = 1; i < argc; i++) {
|
||||||
const char* arg = argv[i];
|
const char* arg = argv[i];
|
||||||
|
|
||||||
if (arg[0] != '-') {
|
if (arg[0] != '-') {
|
||||||
|
@ -276,7 +278,6 @@ static int sh_pushd(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* real_path = canonical_path.string().characters();
|
const char* real_path = canonical_path.string().characters();
|
||||||
g.directory_stack.append(real_path);
|
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int rc = stat(real_path, &st);
|
int rc = stat(real_path, &st);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue