Build-a-salon-appointment-scheduler-project bug?

This is my code:

#! /bin/bash

PSQL=“psql --username=freecodecamp --dbname=salon --tuples-only -c”

echo -e “\n Select the service you want:\n”

LIST_OF_SERVICES=$($PSQL “SELECT service_id, name FROM services ORDER BY service_id”)

echo “$LIST_OF_SERVICES” | while read SERVICE_ID BAR NAME

do

ID=$(echo $SERVICE_ID | sed ‘s/ //g’)

SERVICE=$(echo $NAME | sed ‘s/ //g’)

echo “$ID) $NAME”

done

read SERVICE_ID_WANTED

And " You should display a numbered list of the services you offer before the first prompt for input, each with the format #) <service> . For example, 1) cut , where 1 is the service_id" doesn’t appear checked. Why?

  1. The quotes around PSQL=“psql --username=freecodecamp --dbname=salon --tuples-only -c” are the wrong type of quotes. They should be straight quotes ("), not smart quotes (“”). This can cause the variable to not be set properly and lead to errors down the line.
  2. The variable LIST_OF_SERVICES is not being properly quoted in the while loop, which can cause issues with whitespace and special characters in the service names.
  3. The echo statement inside the while loop is using $NAME instead of $SERVICE, which could cause the output to appear incorrectly.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.