* variable substitution The test for the read command might fail consistently due to "ls -l /tmp" as the test case and the contents of "/tmp" changing while the test is running. Login with a regular SSH program (not vscode) and rerun to reduce the likelihood of this. * how does the environment work when you execute a script? The process environment: a vector of char * values in the form name=value The shell environment: an array of structs with the env vars and field to indicate whether the variable is exported The process environment is one thing that doesn't change when you call execvp ... which calls execve with environ as the e argument. * when reading from a script? Everything works the same, _except_: * no prompt * smsh input and read builtin input are from different sources script for smsh input and stdin for read * source builtin Temporarily replaces the command input source. At EOF, return to the original input source. ** basic idea smsh starts up and determines it input source (e.g., av[1] is a script) fopen av[1], that is now the command input source read cmd by cmd from command input source encounter ". somescript.sh" fopen somescript.sh read cmd by cmd from somescript.sh until EOF a common approach is move the "while next_cmd" loop out of main into a helper function (e.g., command_loop) that takes a FILE* as arugment. in main, call command_loop in the dot builtin handling, call command_loop with a FILE* for the specified script * command subtitution execute a command in a child process and that output will be the substitution value. echo $(date) --> execute date in a child process, capture the output, and then execute "echo " 1. parse out the command line from between '(' and ')' 2. use a pipe to connect the childs output to the parent for reading 3. fork and handle in the same way as inside the next_cmd loop a. in child: dup the write end of the pipe to stdout before executing the command via process b. in parent: read from the read end of the pipe, capture that data for replacement on EOF, call wait * your smsh doesn't have to support input or output redirection but how would you do that? parse the command line looking for redirection symbols when you find one - remember the current input/output - open the redirection source, use dup to replace - execute the command - close the redirection source - restore the original input/output