This program is a basic command-line interpreter with features without which there can be no shell. As a reference, i've taken zsh. During developing was implemented:
-
default prompt looks like u$h> , followed by a space character
-
builtin commands without flags:
Command Description export [name[=value] ...] Set an environment variable with specified name unset name ... Delete given shell variable. exit [n] Exit the shell with the exit status specified by n expression, if none is specified, exit with 1 status. -
builtin commands with flags:
Command Description env Set each NAME to VALUE in the environment and run COMMAND
-i - start with an empty environment
-P altpath - Search the set of directories as specified by altpath to locate the specified utility program, instead of using the value of the PATH environment variable.
-u name - remove variable from the environmentcd Change current directory.
-s - cd refuses to change the current directory if the given pathname contains symlinks
-P - symbolic links are resolved to their true values
--
- change to the previous directorypwd [-LP] Print the absolute pathname of the current working directory
-L - he default one
-P - if -L flag is not given, the printed path will not contain symbolicwhich [-as] name For each name, indicate how it would be interpreted if used as a command name. If name is not a built-in command or a reserved word, the exit status shall be non-zero, and a message will be written to standard error.
-a - do a search for all occurrences of name throughout the command path. Normally only the first occurrence is printed.
-s - if a pathname contains symlinks, print the symlink-free pathname as well.echo [-neE] [arg ...] Write each arg on the standard output, with a space separating each one.
-n - do not output the trailing newline
-e - enable interpretation of backslash escapes
-E - disable interpretation of backslash escapes (default) -
calling the builtin command instead of the binary program if there is a name match among them
-
correct managing errors
-
correct managing user environment
-
running programs located in the directories listed in the PATH variable
-
the command separator ;
-
managing these expansions correctly:
- the tilde expansion ~ with the following tilde-prefixes: ~ , ~/dir_name , ~username/dir_name , ~+/dir_name , ~-/dir_name
- the basic form of parameter expansion ${parameter}
- the two-level-nested command substitution $(command
This program was developed on the MacOS, so it works correctly there.
In folder with cloned project use make
to compile project. Start program with ./ush
.
To delete the program - make uninstall
To delete all 'obj' files - make clean
To reinstall the program - make reinstall