minor changed
This commit is contained in:
14
msh.c
14
msh.c
@@ -133,7 +133,15 @@ char *getPrompt() {
|
|||||||
dup2(output.write, STDOUT_FILENO);
|
dup2(output.write, STDOUT_FILENO);
|
||||||
close(STDERR_FILENO); // Do not print errors to the screen
|
close(STDERR_FILENO); // Do not print errors to the screen
|
||||||
|
|
||||||
execlp("bash", "bash", "-i", "-c", "echo \"${PS1@P}\"", NULL);
|
execlp("bash", "bash", "-i", "-c", "\
|
||||||
|
ver=$(bash --version | head -n 1 | awk \'{print $4}\' | grep -o \"...\");\
|
||||||
|
check_ver=$(echo -e \"${ver}\n4.3\" | sort -V | head -n 1);\
|
||||||
|
if [[ \"${ver}\" == \"${check_ver}\" ]]; then\
|
||||||
|
echo \"[${USER}@${pwd}]\";\
|
||||||
|
else\
|
||||||
|
echo \"${PS1@P}\";\
|
||||||
|
fi\
|
||||||
|
", NULL);
|
||||||
} else if (pid < 0) { // Error forking
|
} else if (pid < 0) { // Error forking
|
||||||
printf("Error forking\n");
|
printf("Error forking\n");
|
||||||
} else { // Parent process
|
} else { // Parent process
|
||||||
@@ -154,10 +162,6 @@ char *getPrompt() {
|
|||||||
} while(!WIFEXITED(status) && !WIFSIGNALED(status));
|
} while(!WIFEXITED(status) && !WIFSIGNALED(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != 0) {
|
|
||||||
prompt = ">> ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user