0

What’s wrong with this code?

#!/bin/bash
ARCH=$(uname -m)
if ["$ARCH" = "i686"]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 32-Bit"
if ["$ARCH" = "x86_64"];then
 zenity --info --title="Architechture Checker" --text= "Your Architechture is 64-Bit"

2 Answers 2

9
  1. No matching "fi" for the "if"s

  2. You need to put whitespace around "[" and "]"

  3. Space after "--text=" makes the parameter get lost.

Working version:

#!/bin/bash
ARCH=$(uname -m)
if [ "$ARCH" = "i686" ]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 32-Bit"
fi
if [ "$ARCH" = "x86_64" ]; then
 zenity --info --title="Architechture Checker" --text="Your Architechture is 64-Bit"
fi
4

Or, using case instead (and also a function to shorten it a bit).

#!/bin/bash

zinfo() { zenity --info --title="Architecture Checker" --text="$1"; }

case $(uname -m) in
  i686) zinfo "Your architecture is 32-bit" ;;
  x86_64) zinfo "Your architecture is 64-bit" ;;
  *) zinfo "Your architecture is unknown to me" ;;
esac

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .