From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Mon, 27 Jan 2014 10:03:04 -0700 Subject: [U-Boot] [PATCH V2 2/5] fs: implement infra-structure for an 'exists' function In-Reply-To: References: <1390507020-15766-1-git-send-email-swarren@wwwdotorg.org> <1390507020-15766-2-git-send-email-swarren@wwwdotorg.org> Message-ID: <52E69148.5040400@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/26/2014 08:41 AM, Simon Glass wrote: > Hi Stephen, > > On 23 January 2014 12:56, Stephen Warren > wrote: > > From: Stephen Warren > > > This could be used in scripts such as: > > if exists mmc 0:1 /boot/boot.scr; then > load mmc 0:1 ${scriptaddr} /boot/boot.scr > source ${scriptaddr} > fi ... > Acked-by: Simon Glass > > > Seems useful. > > In addition, if it is just the error messages you are worried about (and > I agree they should be eliminated) I wonder if we should consider adding > a -e flag (or similar) to the read command to make it silently fail when > the file does not exist? Arguably your code fragment above could be: > > if load -e mmc 0:1 ${scriptaddr} /boot/boot.scr; then > source ${scriptaddr} > fi That would certainly work, although I think a direct check of file-existence is more in line with how a regular Unix shell script would work (test -e). I could imagine wanting to test for the existence of a file without caring about its contents (e.g. using a file as a flag to trigger a firmware upgrade or something)