Commit 13976cda authored by Peter Dave Hello's avatar Peter Dave Hello

Declare and assign variable separately in Shell Script

To avoid masking return values, declare and assign separately.

Reference:
- https://github.com/koalaman/shellcheck/wiki/SC2155
parent 1bc00204
......@@ -9,7 +9,8 @@ mail_room_config="$app_root/config/mail_room.yml"
get_mail_room_pid()
{
local pid=$(cat $mail_room_pidfile)
local pid
pid=$(cat $mail_room_pidfile)
if [ -z "$pid" ] ; then
echo "Could not find a PID in $mail_room_pidfile"
exit 1
......
......@@ -9,7 +9,8 @@ unicorn_cmd="bundle exec unicorn_rails -c $unicorn_config -E $RAILS_ENV"
get_unicorn_pid()
{
local pid=$(cat $unicorn_pidfile)
local pid
pid=$(cat $unicorn_pidfile)
if [ -z "$pid" ] ; then
echo "Could not find a PID in $unicorn_pidfile"
exit 1
......
---
title: Declare and assign variable separately in Shell Script
merge_request: 46121
author: Peter Dave Hello @PeterDaveHello
type: other
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment