Skip to content
Snippets Groups Projects

Fix workhorse-stunnel bash syntax

Closed username-removed-444214 requested to merge workhorse-stunnel-syntax into master

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
11 11 EOF
12 12 }
13 13
14 if [ x$# -ne x3 ] ; then
14 if [ "$#" -ne 3 ] ; then
  • Jacob Vosmaer (GitLab) Status changed to closed

    Status changed to closed

  • @jacobvosmaer-gitlab You can use -ne to compare the number of args. The issue is with the x's within the conditional statement.

  • @MrChrisW OK! I think it works now on master, can you confirm?

  • username-removed-444214 Status changed to reopened

    Status changed to reopened

  • @jacobvosmaer-gitlab Hey! The syntax is ok now I'm just wondering why you've got the x character in the conditional statement ?

    image

  • @MrChrisW defensive programming. http://stackoverflow.com/questions/174119/why-do-shell-script-comparisons-often-use-xvar-xyes

    But now that I read more about it I suppose the best thing to do is "x$foo = x3" to protect against spaces.

    In this particular case I suppose we can treat $# as a trusted input though so I'll drop the x's. http://pubs.opengroup.org/onlinepubs/009604499/utilities/xcu_chap02.html#tag_02_05_02

  • @jacobvosmaer-gitlab Really appreciate the explanation, i wasn't aware of using additional chars to avoid an edge case of empty variables!

  • username-removed-444214 Status changed to closed

    Status changed to closed

  • @MrChrisW you're welcome, thanks for asking and again thanks for the MR!

  • Please register or sign in to reply
    Loading