![]() |
Quote:
Quote:
|
Well, certain things get parsed at log in with hard coded variables in OS X, so when a script runs as a log in hook, $1 is always something, $2 is always something, so I was assuming that login hooks sourced some commands which output the desired result to $1.
So, in my case, if I sourced my global variables, and say the currently logged in user is output to $1 I could do this in a script defaults write /Users/$1/Library/Preferences/com.mycompany "some_options" -bool true I think I want to build functions, but just not sure how to set them to certain variables. I know some third party stuff also uses $1, $2, $3 at log in to utilize certain hard coded variables. Sorry if I am not making much sense |
Third party stuff does not set $1, $2, etc to values - as I said before, those values come from the command-line args used when the script was invoked.
I'm not sure what you are missing - i.e. why the sort of example (with suggested variable names) I gave above is not what you want. |
Quote:
I guess, I don't have to output it to a number, but I was thinking it may be easiest that way. Thanks |
Quote:
|
Quote:
|
Quote:
From post #2: Quote:
Quote:
# SHELL SCRIPT: $ cat foo Code:
# CONFIG FILE: $ cat .myConfigs Code:
And, here is what it looks like when it's run: Code:
BTW... Quote:
|
I was thinking I could pass a bunch of arguments to a function and then just call that function in a script. I could, case things for different OS versions and what not. Though, this is getting slightly above my skill level, but I am willing to learn.
I just think numbers would be easier than word variables, but then again as long as I am writing everything I can kind of do it how I want. I was thinking more along the lines of setting this up, so when other people in my department need to write a script they can call global variables for simple one liners instead of hashing everything out. Thanks |
Still using my foo script from post #27, perhaps this run (including some args on the command line this time) will better illustrate what's happening:
Code:
$ foo these are arguments |
| All times are GMT -5. The time now is 05:51 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.