1#!/bin/ksh 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2020 Joyent, Inc. 15# 16 17# 18# Clearly, grossly incomplete. 19# 20 21export LC_ALL=C.UTF-8 22 23set -o pipefail 24unalias -a 25 26find_prog=/usr/bin/find 27find_prog_xpg4=/usr/xpg4/bin/find 28find_dir="$(mktemp -d -p /tmp/)" 29find_exit=0 30 31testfind() 32{ 33 exp=$1 34 shift 35 cmd="$@" 36 37 echo "TEST: $cmd" 38 39 out=$(eval $cmd | tr '\n' ',') 40 41 [[ "$exp" = "$out" ]] || { 42 echo "TEST FAILED: $cmd" >&2 43 echo "expected: $exp" >&2 44 echo "got: $out" >&2 45 find_exit=1 46 } 47} 48 49mkdir -p $find_dir/1 50mkdir -p $find_dir/.2 51touch $find_dir/.2/1 52touch $find_dir/.2/c 53 54testfind "$find_dir/1,$find_dir/.2/1," \ 55 $find_prog $find_dir -name \"1\" 56testfind "$find_dir/1,$find_dir/.2/1," \ 57 $find_prog $find_dir -path \"*1\" 58 59cd $find_dir 60 61testfind "" $find_prog . -name \"*2\" 62testfind "./.2," $find_prog_xpg4 . -name \"*2\" 63testfind "./.2," $find_prog . -name \".*2\" 64testfind "./.2," $find_prog_xpg4 . -name \".*2\" 65testfind "./1,./.2/1," $find_prog . -path \"*1\" 66testfind "./.2," $find_prog . -path \"*2\" 67testfind "./.2,./.2/1,./.2/c," $find_prog . -path \"*2*\" 68 69cd - 70rm -rf $find_dir 71 72exit $find_exit 73