ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thanks for your patients with my old slow learning brain.
I have not been able to figure out why this fails.
if [[ -n "$1" ]]; then I have also tried
if [[ -z "$1" ]]; then which only fails the other way.
The variable $1 is the first passed into the function this is part of and contains something like 20:34 which is a time that is used in a different function to schedule an "at" job.
The line above needs to "add" or "omit" some text that is dumped into a file for latter processing based on if this time data exists or not. Because it fails the whole function fails to generate the proper files. :Grrrrr:
In a different part of the larger project there in an almost identical line that works just fine.
if [[ -n "$YOMTOVE" ]]; then
The only difference that I know of is that this one has words in the variable like "Pesach" and the other one has the time as I mentioned before.
$ var="20:34"
$ if [[ -n "$var" ]]; then echo 1; fi
1
$ if [[ -z "$var" ]]; then echo 1; fi
$ var=""
$ if [[ -n "$var" ]]; then echo 1; fi
$ if [[ -z "$var" ]]; then echo 1; fi
1
I found the issue. The variable is not being unset as I thought it would in the calling loop. It occurred to me while I was eating dinner. Checked it out an sure enough that's it. Now all I have to do is figure out the best way to do it.
Can I pass it in like the red text making it unset?
That did the trick. I think I only have one left. Think being the operative word. Also the variable issue I was having in a different thread, I did not need not need to export them.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.