I would recommend that instead of using pushd/popd, try redesigning your code flow to run the necessary commands in "()" subshell brackets. When the subshell exits, its environment is lost, and you're automatically back to where you started without having to do anything.
Example: Code:
#!/bin/sh |
And to reiterate a couple of things:
When you use "#!/bin/sh", the script is interpreted as a POSIX-compliant script. So if you want to use arrays or other bashisms, be sure to make the shebang "#!/bin/bash", and conversely if you need to use "#!/bin/sh" explicitly, then do not use arrays or other bashisms. (Watch that you type it correctly, too. No spaces.) And since I don't think I've yet stated it unambiguously: QUOTE ALL OF YOUR VARIABLE EXPANSIONS. You should never leave the quotes off a parameter expansion unless you explicitly want the resulting string to be word-split by the shell and possible globbing patterns expanded. This is a vitally important concept in scripting, so train yourself to do it correctly now. You can learn about the exceptions later. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes This generally means that if it begins with a "$", then double-quote it. If it's a string that has spaces or other weird characters in it, also single or double quote it. The general rule of thumb is also to try to quote the longest string possible. e.g.: Code:
echo "There's already a directory named ${line[0]}" |
I agree with the above comments by "David the H," but - to muddy the water slightly - I like to at least try to make my comments grammatically correct. viz:
Code:
echo "A directory named \"${line[0]}\" already exists." >&2 |
Unless I'm breaking something, I think I have one more script to go. I'll retest after this, just to make sure though. Unfortunately, I'm stuck again and this time with no errors.
File to translate: Code:
@ECHO OFF csoftwarefolders.sh: Code:
#! /bin/sh Code:
#! /bin/sh Code:
#! /bin/sh Code:
#! /bin/sh Code:
#! /bin/sh Code:
#! /bin/sh |
The new syntax of the deeper files is:
XP.sdr Code:
HOME /etc/settings/Operating_Systems/windows/none.sdr Code:
des |
Here's the correct output:
|
Sorry about this, the system is saying my posts are too long. I'm going to have to break it up.
|
Here's the correct output (p1):
Code:
ÃÄÄÄBACKUP |
(p2):
Code:
ÃÄÄÄCUSTOM |
(p3):
Code:
ÃÄÄÄOPERATING_SYSTEMS |
But the output it's giving me is:
Code:
├── BACKUP |
Sorry about the messyness of the tree commands, it's just the way they came out, but it should still be readable...
|
Quote:
|
Quote:
So all this time I've been putting spaces, and it's incorrect? These scripts are supposed to be run in bash. sh, is a link to bash. |
This problem is solved now.
mknasosnames2.sh Code:
#! /bin/sh |
All times are GMT -5. The time now is 06:22 PM. |