7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# CDDL HEADER START
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# The contents of this file are subject to the terms of the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# You may not use this file except in compliance with the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# See the License for the specific language governing permissions
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# and limitations under the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# When distributing Covered Code, include this CDDL HEADER in each
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# If applicable, add the following below this CDDL HEADER, with the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# fields enclosed by brackets "[]" replaced with your own identifying
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# information: Portions Copyright [yyyy] [name of copyright owner]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# CDDL HEADER END
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# Solaris needs /usr/xpg6/bin:/usr/xpg4/bin because the tools in /usr/bin are not POSIX-conformant
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinexport PATH=/usr/xpg6/bin:/usr/xpg4/bin:/bin:/usr/bin
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# Make sure all math stuff runs in the "C" locale to avoid problems
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# with alternative # radix point representations (e.g. ',' instead of
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# '.' in de_DE.*-locales). This needs to be set _before_ any
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# floating-point constants are defined in this script).
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin find "${basedir}"/* -prune 2>/dev/null | while read i ; do
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -r "$i" ]] && nflags.readable="true" || nflags.readable="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -w "$i" ]] && nflags.writeable="true" || nflags.writeable="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -x "$i" ]] && nflags.executable="true" || nflags.executable="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -b "$i" ]] && nflags.blockdevice="true" || nflags.blockdevice="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -c "$i" ]] && nflags.characterdevice="true" || nflags.characterdevice="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -S "$i" ]] && nflags.socket="true" || nflags.socket="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin [[ -L "$i" ]] && nflags.symlink="true" || nflags.symlink="false"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin ( [[ -x /usr/bin/runat ]] && ls -@ade "$i" || ls -lade "$i" ) |
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin # note that /usr/xpg4/bin/file does not use $'\t' as seperator - we
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin getopts -a "${progname}" "${filetree1_usage}" OPT '-?'
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# program start
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz[-?\n@(#)\$Id: filetree1 (Roland Mainz) 2009-05-06 \$\n]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin[-author?Roland Mainz <roland.mainz@sun.com>]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin[-author?Roland Mainz <roland.mainz@nrubsig.org>]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin[+NAME?filetree1 - file tree demo]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin[+DESCRIPTION?\bfiletree1\b is a small ksh93 compound variable demo
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin which accepts a directory name as input, and then builds tree
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin nodes for all files+directories and stores all file attributes
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin in these notes and then outputs the tree in the format
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainz specified by viewmode (either "list", "namelist", "tree" or "compacttree")..]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinviewmode dirs
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin[+SEE ALSO?\bksh93\b(1), \bfile\b(1)]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chinwhile getopts -a "${progname}" "${filetree1_usage}" OPT ; do
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin# printmsg "## OPT=|${OPT}|, OPTARG=|${OPTARG}|"
34f9b3eef6fdadbda0a846aa4d68691ac40eace5Roland Mainzif [[ "${viewmode}" != ~(Elr)(list|namelist|tree|compacttree) ]] ; then
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin fatal_error $"Invalid view mode \"${viewmode}\"."
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin fatal_error $"Invalid view mode \"${viewmode}\"."