Skip to main content
deleted 1 character in body
Source Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

This line has readability problems:

if [ "$1" = "$string" ] && { ! ([ -z "$3" ] || [ -z "$3" ]) }

You put $3 twice; I assume you meant $2 for one of them.

Since "$string" is just install, you might as well say install instead.

The compound conditional, is hard to understand. Apply De Morgan's laws to obtain

if [ "$1" = install ] && ! [ -z "$2" ] && ! [ -z "$3" ]

… which is just

if [ "$1" = install ] && [ -n "$2" ] && [ -n "$3" ]

I would introduce explaining variables

command="$1"
username="$2"
password="$3"
if [ "$command" = install ] && [ -n "$username" ] && [ -n "$password" ]

This line has readability problems:

if [ "$1" = "$string" ] && { ! ([ -z "$3" ] || [ -z "$3" ]) }

You put $3 twice; I assume you meant $2 for one of them.

Since "$string" is just install, you might as well say install instead.

The compound conditional, is hard to understand. Apply De Morgan's laws to obtain

if [ "$1" = install ] && ! [ -z "$2" ] && ! [ -z "$3" ]

… which is just

if [ "$1" = install ] && [ -n "$2" ] && [ -n "$3" ]

I would introduce explaining variables

command="$1"
username="$2"
password="$3"
if [ "$command" = install ] && [ -n "$username" ] && [ -n "$password" ]

This line has readability problems:

if [ "$1" = "$string" ] && { ! ([ -z "$3" ] || [ -z "$3" ]) }

You put $3 twice; I assume you meant $2 for one of them.

Since "$string" is just install, you might as well say install instead.

The compound conditional is hard to understand. Apply De Morgan's laws to obtain

if [ "$1" = install ] && ! [ -z "$2" ] && ! [ -z "$3" ]

… which is just

if [ "$1" = install ] && [ -n "$2" ] && [ -n "$3" ]

I would introduce explaining variables

command="$1"
username="$2"
password="$3"
if [ "$command" = install ] && [ -n "$username" ] && [ -n "$password" ]
Source Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

This line has readability problems:

if [ "$1" = "$string" ] && { ! ([ -z "$3" ] || [ -z "$3" ]) }

You put $3 twice; I assume you meant $2 for one of them.

Since "$string" is just install, you might as well say install instead.

The compound conditional, is hard to understand. Apply De Morgan's laws to obtain

if [ "$1" = install ] && ! [ -z "$2" ] && ! [ -z "$3" ]

… which is just

if [ "$1" = install ] && [ -n "$2" ] && [ -n "$3" ]

I would introduce explaining variables

command="$1"
username="$2"
password="$3"
if [ "$command" = install ] && [ -n "$username" ] && [ -n "$password" ]