Skip to content

Commit

Permalink
Quit if path specified in -f/--fifo option does not exist
Browse files Browse the repository at this point in the history
If FIFO path is specified via -f/--fifo option and if that path does not
exist, then it is considered an error and the script quits, i.e. if
-f/--fifo option is used, the script doesn't check ~/.weechat for the
FIFO file anymore. The script checks ~/.weechat if and only if -f/--fifo
option is not used.
  • Loading branch information
susam committed Jan 22, 2017
1 parent 768fa03 commit 1d98d14
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions inwee
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,32 @@ main()
{
parse_arguments "$@"

# Find FIFO path via the -f|--fifo argument.
if [ -e "$fifo_path" ]; then
debug_output "Found FIFO socket on custom argument."
fifo="$fifo_path"
else
debug_output "Could not find FIFO socket on custom argument."
fi

# Find FIFO pipe via the PID method.
for f in ~/.weechat/weechat_fifo*
do
if [ "$f" != ~/.weechat/weechat_fifo_"*" ]; then
fifo="$f"
break
if [ -n "$fifo_path" ]
then
# Find FIFO path via the -f|--fifo argument.
if [ -e "$fifo_path" ]
then
debug_output Found FIFO socket on custom argument.
fifo="$fifo_path"
else
debug_output "Could not find FIFO socket via PID method."
quit Cannot find specified FIFO path.
fi
done
else
# Find FIFO pipe in ~/.weechat.
for f in ~/.weechat/weechat_fifo*
do
if [ "$f" != ~/.weechat/weechat_fifo"*" ]
then
debug_output Found FIFO socket in ~/.weechat.
fifo="$f"
break
fi
done
fi

if [ -z "$fifo" ]; then
quit Could not find Weechat FIFO pipe.
if [ -z "$fifo" ]
then
quit Cannot find Weechat FIFO pipe.
fi

debug_output FIFO: "$fifo"
Expand Down Expand Up @@ -184,19 +189,19 @@ quit()
show_help()
{
printf "%s\n" \
"Usage: $NAME [-b BUFFER] [-d] [-c] [-h] [-v] [FILE]
"Usage: $NAME [-b BUFFER] [-f FIFO] [-d] [-c] [-h] [-v] [FILE]
Read text or commands from standard input, FILE or from the output of a
shell command, and send it to WeeChat's FIFO pipe. If FILE is not
specified or if it is specified as '-', i.e. a hyphen, then text and
commands are read from standard input.
Options:
-b, --buffer BUFFER Buffer to send text or command to.
-fp, --fifo-path PATH FIFO Path to send commands to.
-d, --debug Show diagnostic information.
-h, --help Show this help and exit.
-v, --version Show version and exit.
-b, --buffer BUFFER Buffer to send text or command to.
-f, --fifo FIFO FIFO Path to send commands to.
-d, --debug Show diagnostic information.
-h, --help Show this help and exit.
-v, --version Show version and exit.
Report bugs to <$SUPPORT_URL>."
}
Expand Down

0 comments on commit 1d98d14

Please sign in to comment.