Bug 5411 - Do proper checks for unset variables in scripts
Summary: Do proper checks for unset variables in scripts
Status: CLOSED WONTFIX
Alias: None
Product: ThinLinc
Classification: Unclassified
Component: Misc (show other bugs)
Version: trunk
Hardware: PC Unknown
: P2 Normal
Target Milestone: 4.7.0
Assignee: Pierre Ossman
URL:
Keywords:
Depends on: 5099
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-29 10:31 CET by Samuel Mannehed
Modified: 2016-07-13 11:10 CEST (History)
1 user (show)

See Also:
Acceptance Criteria:


Attachments
use ${VAR+x} when checking variables (by Daniel Eischen) (2.97 KB, patch)
2015-01-29 10:37 CET, Samuel Mannehed
Details

Description Samuel Mannehed cendio 2015-01-29 10:31:24 CET
If you use -u (treat unset varibles as errors):

>   kinit is /usr/kerberos/bin/kinit
>   /opt/thinlinc/etc/xstartup.d/01-tl-kinit.sh: line 11: KRB5CCNAME: unbound
> variable
>    X connection to :1.0 broken (explicit kill or server shutdown).

The way we check for unset variables causes this error:

 -z "${VAR}"

We should do:

 -z "${VAR+}"

or 

 -z "${VAR+x}"
Comment 2 Samuel Mannehed cendio 2015-01-29 10:36:42 CET
(In reply to comment #0)
> We should do:
> 
>  -z "${VAR+}"
> 
> or 
> 
>  -z "${VAR+x}"

Should be:

-z ${VAR+}

or 

-z ${VAR+x}

without the quotation marks
Comment 4 Pierre Ossman cendio 2015-02-03 13:32:50 CET
Can probably be better solved by implementing bug 5099.
Comment 6 Pierre Ossman cendio 2016-07-12 17:10:27 CEST
This is now no longer necessary with the changes in bug 5099. Our scripts no longer execute in a login shell mode. Hence we do not need this defensive programming style.

Note You need to log in before you can comment on or make changes to this bug.