source: vendor/bash/3.1-p17/examples/functions/emptydir

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 599 bytes
Line 
1#! /bin/bash
2#
3#Derived from:
4#
5#From: damercer@mmm.com (Dan Mercer)
6#Newsgroups: comp.unix.admin,comp.unix.shell,comp.unix.programmer,comp.sys.sun.admin
7#Subject: Re: Command to find out if a directory is empty
8#Date: 17 Aug 2000 14:35:56 GMT
9#Message-ID: <8ngt8c$fmr$1@magnum.mmm.com>
10
11# usage: emptydir [dirname] ; default dirname is "."
12
13emptydir()
14{
15 typeset file dir=${1:-.}
16 [[ -d $dir ]] || {
17 echo "$FUNCNAME: $dir is not a directory" >&2
18 return 2
19 }
20 for file in $dir/.* $dir/*
21 do
22 case ${file#$dir/} in
23 .|..) ;;
24 \*) [[ -e $file ]];let $?;return;;
25 *) return 1;;
26 esac
27 done
28}
Note: See TracBrowser for help on using the repository browser.