use argv[1] as argument for cwd
This commit is contained in:
parent
b2cd0bf431
commit
4342300e56
1 changed files with 12 additions and 1 deletions
13
ccc.c
13
ccc.c
|
@ -54,6 +54,13 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (argc > 1 && strcmp(argv[1], "-h") == 0)
|
if (argc > 1 && strcmp(argv[1], "-h") == 0)
|
||||||
die("Usage: ccc filename");
|
die("Usage: ccc filename");
|
||||||
|
if (argc == 2) {
|
||||||
|
struct stat st;
|
||||||
|
if (lstat(argv[1], &st) != 0) {
|
||||||
|
perror("ccc");
|
||||||
|
die("Error from lstat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* check if it is interactive shell */
|
/* check if it is interactive shell */
|
||||||
if (!isatty(STDIN_FILENO))
|
if (!isatty(STDIN_FILENO))
|
||||||
|
@ -92,8 +99,12 @@ int main(int argc, char** argv)
|
||||||
marked = arraylist_init(100);
|
marked = arraylist_init(100);
|
||||||
|
|
||||||
cwd = memalloc(PATH_MAX * sizeof(char));
|
cwd = memalloc(PATH_MAX * sizeof(char));
|
||||||
|
if (argc == 2) {
|
||||||
|
strcpy(cwd, argv[1]);
|
||||||
|
} else {
|
||||||
|
getcwd(cwd, PATH_MAX);
|
||||||
|
}
|
||||||
p_cwd = memalloc(PATH_MAX * sizeof(char));
|
p_cwd = memalloc(PATH_MAX * sizeof(char));
|
||||||
getcwd(cwd, PATH_MAX);
|
|
||||||
populate_files(cwd, 0);
|
populate_files(cwd, 0);
|
||||||
start_ccc();
|
start_ccc();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue