Glavin001 / MrShell

Map-Reduce inspired Shell.
MIT License
4 stars 1 forks source link

Basic Built-In Shell Functions/Features #16

Closed Glavin001 closed 9 years ago

Glavin001 commented 9 years ago
Glavin001 commented 9 years ago

See http://stackoverflow.com/a/11958481/2578205 for obtaining the current Git branch.

@Frozenfire92 's dotfiles: https://github.com/Frozenfire92/dotfiles/blob/master/.bash_profile

Glavin001 commented 9 years ago

Quick brief of how I'd do it, for anyone interested, before I go pass out: 1) Iterate linearly thru all command line args (argv[0], argv[1], argv[2]). Let's deal with argv[0] from here on, the first arg. 2) Any time where the first character (argv[0][0]) is equal to the char "~" then continue with step 3 3) use malloc to allocate a char array with the size of $HOME plus the original argv[0] length minus 1 (for the ~ that is removed in argv[0]). This will be the new length of that argv[0]. 4) Starting from the beginning, fill the char array with the chars in $HOME 5) Next, starting at the end where $HOME left off, in the new char array, continue with the original contents of the char array in argv[0], starting at argv[0][1](skipping argv[0][0] which is the ~ to be removed). You have now filled the contents of the char array with the resolved path. Your new char array for the argv[0] is now stored in your new char array. Switch the pointers of argv[0] to the new array and dealloc the old argv[0]. Apply this function to every argument, in either the parse or execute function. This will allow us to support:

Glavin001 commented 9 years ago

All done!