Gentoo Archives: gentoo-user

From: Stroller <stroller@××××××××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] Kinda "try ... catch" in a shell script...how
Date: Sat, 10 Mar 2018 13:28:08
Message-Id: 577610A3-EE5B-40A4-877E-79AA2F1A355B@stellar.eclipse.co.uk
In Reply to: [gentoo-user] [OT] Kinda "try ... catch" in a shell script...how by tuxic@posteo.de
1 > On 10 Mar 2018, at 08:26, tuxic@××××××.de wrote:
2 > ...
3 >
4 > As soon the file is not found, the script ends with an 'Not found'
5 > error, which '-f' is exactly for, because the expanding comes before
6 > the '-f'...
7 >
8 > So I need something else or a try-catch-thingy to make that work...but
9 > how?
10 >
11 > Or do I miss the forest for the trees here... ;)
12
13 I don't get that at all with this snippet:
14
15 $ cat test.sh
16 #!/bin/bash
17 if [ -f foo* ] ; then
18 echo "foo exists"
19 fi
20 $
21
22 This makes me suspect you've got `#!bash -x` (or -e?) as your first line, or something.
23
24 When you encounter a problem you don't understand, create the most minimal program you can to reproduce the problem. If you can't reproduce it, add to it one step at a time until it becomes what you're trying to do.
25
26 Stroller