Lines Matching +full:multi +full:- +full:function

20 # program may be set up to operate interactively (-i), to not touch a file if it
21 # already exists (-n), and to forcefully remove it anyways (-f). cp implements
22 # -i and -n, -f means something different. mv implements all three flags. ln
23 # implements -i and -f (-n is a pseudo-default).
26 unalias -a
27 set -o pipefail
28 export LANG=C.UTF-8
33 MV=${MV:-"/usr/bin/mv"}
34 XMV=${XMV:-"/usr/xpg4/bin/mv"}
35 CP=${CP:-"/usr/bin/cp"}
36 XCP=${XCP:-"/usr/xpg4/bin/cp"}
37 LN=${LN:-"/usr/bin/ln"}
38 XLN=${XLN:-"/usr/xpg4/bin/ln"}
47 typeset -A ovr_files=(
57 ["dir/a"]=(type="file-dm" path="$ovr_work/dir/a")
59 ["dir/c"]=(type="noperms-dm" path="$ovr_work/dir/c")
60 ["dir/fifo"]=(type="fifo-dm" path="$ovr_work/dir/fifo")
61 ["dir/door"]=(type="door-dm" path="$ovr_work/dir/door")
62 ["dir/uds"]=(type="uds-dm" path="$ovr_work/dir/uds")
63 ["dir/symlink"]=(type="symlink-dm" path="$ovr_work/dir/symlink")
64 ["dir/dangle"]=(type="dangle-dm" path="$ovr_work/dir/dangle")
67 function fatal
74 function warn
81 function cleanup
83 rm -rf $ovr_work/
89 function setup_files
107 $ovr_mkobj -f $targ || fatal "failed to make fifo"
110 $ovr_mkobj -d $targ || fatal "failed to make door"
113 $ovr_mkobj -s $targ || fatal "failed to make uds"
116 ln -s ${ovr_files["b"].path} $targ || \
120 ln -s "$ovr_work/enoent" $targ || \
124 mkdir -p $targ || fatal "failed to make directory"
136 function check_files
159 if ! $ovr_check -n $targ; then
165 if [[ ! -p $targ ]]; then
167 "a pipe: $(ls -l $targ)"
172 if ! $ovr_check -d $targ; then
178 if [[ ! -S $targ ]]; then
180 "a socket: $(ls -l $targ)"
185 if [[ ! -L $targ ]]; then
187 "a symlink: $(ls -l $targ)"
192 if [[ ! -d $targ ]]; then
205 function check_data
224 function exp_fail
229 typeset -a args
253 function exp_pass
261 typeset -a args
268 if [[ -z "$pipe" ]]; then
275 set -o pipefail
284 check_data "$desc" "${args[-1]}" "$expect" && \
292 function exp_retain
297 typeset -a args
321 function exp_dir
331 typeset -a args
338 if [[ -z "$pipe" ]]; then
345 set -o pipefail
368 # Start with ln which should fail without -f. Same with ln -s (a different code
379 exp_fail "ln -s doesn't clobber a file (ln -s a b)" "$LN -s" "a b"
380 exp_fail "ln -s doesn't clobber a file without perms (ln -s a c)" "$LN -s" "a c"
381 exp_fail "ln -s doesn't clobber a uds (ln -s a uds)" "$LN -s" "a uds"
382 exp_fail "ln -s doesn't clobber a fifo (ln -s a fifo)" "$LN -s" "a fifo"
383 exp_fail "ln -s doesn't clobber a door (ln -s a door)" "$LN -s" "a door"
384 exp_fail "ln -s doesn't clobber a valid symlink (ln -s a symlink)" "$LN -s" \
386 exp_fail "ln -s doesn't clobber a dangling symlink (ln -s a dangle)" "$LN -s" \
391 # have -f specified and therefore can't open the file without permissions or
416 # Now we go into -f versions and cases where -f trumps -i. This should cause
421 exp_pass "ln -f clobbers a file (ln -f a b)" "$LN -f" "a b" "a"
422 exp_pass "ln -f clobbers a file without perms (ln -f a c)" "$LN -f" "a c" "a"
423 exp_pass "ln -f clobbers a uds (ln -f a uds)" "$LN -f" "a uds" "a"
424 exp_pass "ln -f clobbers a fifo (ln -f a fifo)" "$LN -f" "a fifo" "a"
425 exp_pass "ln -f clobbers a door (ln -f a door)" "$LN -f" "a door" "a"
426 exp_pass "ln -f clobbers a valid symlink (ln -f a symlink)" "$LN -f" \
428 exp_pass "ln -f clobber a dangling symlink (ln -f a dangle)" "$LN -f" \
430 exp_pass "ln -f beats -i on a file (ln -if a b)" "$LN -if" "a b" "a"
431 exp_pass "ln -f beats -i on a file (ln -ifif a b)" "$LN -ifif" "a b" "a"
433 exp_pass "ln -sf clobbers a file (ln -sf a b)" "$LN -sf" "a b" "a"
434 exp_pass "ln -sf clobbers a file without perms (ln -sf a c)" "$LN -sf" "a c" "a"
435 exp_pass "ln -sf clobbers a uds (ln -sf a uds)" "$LN -sf" "a uds" "a"
436 exp_pass "ln -sf clobbers a fifo (ln -sf a fifo)" "$LN -sf" "a fifo" "a"
437 exp_pass "ln -sf clobbers a door (ln -sf a door)" "$LN -sf" "a door" "a"
438 exp_pass "ln -sf clobbers a valid symlink (ln -sf a symlink)" "$LN -sf" \
440 exp_pass "ln -sf clobber a dangling symlink (ln -sf a dangle)" "$LN -sf" \
442 exp_pass "ln -sf beats -i on a file (ln -s -if a b)" "$LN -s -if" "a b" "a"
443 exp_pass "ln -sf beats -i on a file (ln -s -ifif a b)" "$LN -s -ifif" "a b" "a"
446 exp_pass "cp -f clobbers a file (cp -f a b)" "$CP -f" "a b" "a"
447 exp_pass "cp -f clobbers a file without perms (cp -f a c)" "$CP -f" "a c" "a"
448 exp_pass "cp -f clobbers a uds (cp -f a uds)" "$CP -f" "a uds" "a"
449 exp_fail "cp -f leaves a door alone (cp -f a door)" "$CP -f" "a door" "a"
450 exp_pass "cp -f clobbers a valid symlink (cp -f a symlink)" "$CP -f" \
452 exp_pass "cp -f clobber a dangling symlink (cp -f a dangle)" "$CP -f" \
455 exp_pass "mv -f clobbers a file (mv -f a b)" "$MV -f" "a b" "a"
456 exp_pass "mv -f clobbers a file without perms (mv -f a c)" "$MV -f" "a c" "a"
457 exp_pass "mv -f clobbers a uds (mv -f a uds)" "$MV -f" "a uds" "a"
458 exp_pass "mv -f clobbers a fifo (mv -f a fifo)" "$MV -f" "a fifo" "a"
459 exp_pass "mv -f clobbers a valid symlink (mv -f a symlink)" "$MV -f" \
461 exp_pass "mv -f clobber a dangling symlink (mv -f a dangle)" "$MV -f" \
465 # Now cp and mv -n tests. These should leave the target file as is, but pass.
467 exp_retain "cp -n doesn't clobber a file (cp -n a b)" "$CP -n" "a b"
468 exp_retain "cp -n doesn't clobber a file without perms (cp -n a c)" "$CP -n" \
470 exp_retain "cp -n doesn't clobber a uds (cp -n a uds)" "$CP -n" "a uds"
471 exp_retain "cp -n doesn't clobber a fifo (cp -n a fifo)" "$CP -n" "a fifo"
472 exp_retain "cp -n doesn't clobber a door (cp -n a door)" "$CP -n" "a door"
473 exp_retain "cp -n doesn't clobber a valid symlink (cp -n a symlink)" "$CP -n" \
475 exp_retain "cp -n doesn't clobber a dangling symlink (cp -n a dangle)" \
476 "$CP -n" "a dangle"
478 exp_retain "mv -n doesn't clobber a file (mv -n a b)" "$MV -n" "a b"
479 exp_retain "mv -n doesn't clobber a file without perms (mv -n a c)" "$MV -n" \
481 exp_retain "mv -n doesn't clobber a uds (mv -n a uds)" "$MV -n" "a uds"
482 exp_retain "mv -n doesn't clobber a fifo (mv -n a fifo)" "$MV -n" "a fifo"
483 exp_retain "mv -n doesn't clobber a door (mv -n a door)" "$MV -n" "a door"
484 exp_retain "mv -n doesn't clobber a valid symlink (mv -n a symlink)" "$MV -n" \
486 exp_retain "mv -n doesn't clobber a dangling symlink (mv -n a dangle)" \
487 "$MV -n" "a dangle"
490 # -n, -f, and -i interleaving. None of these should cause prompts. non-XPG mv -f
491 # will trump -i anywhere. XPG mv -i working normally is tested later on.
493 exp_retain "cp -n always beats -f (cp -nf a b)" "$CP -nf" "a b"
494 exp_retain "cp -n always beats -f (cp -fn a b)" "$CP -fn" "a b"
495 exp_retain "cp last -n wins (cp -in a b)" "$CP -in" "a b"
496 exp_retain "cp last -n wins (cp -nin a b)" "$CP -nin" "a b"
498 exp_retain "mv last -n wins (mv -in a b)" "$MV -in" "a b"
499 exp_retain "mv last -n wins (mv -fn a b)" "$MV -fn" "a b"
500 exp_retain "mv last -n wins (mv -ifn a b)" "$MV -ifn" "a b"
501 exp_retain "mv last -n wins (mv -fifn a b)" "$MV -fifn" "a b"
502 exp_pass "mv last -f wins (mv -nf a b)" "$MV -nf" "a b" "a"
503 exp_pass "mv last -f wins (mv -if a b)" "$MV -if" "a b" "a"
504 exp_pass "mv last -f wins (mv -fif a b)" "$MV -fif" "a b" "a"
505 exp_pass "mv last -f wins (mv -nif a b)" "$MV -nif" "a b" "a"
506 exp_pass "mv -f always beats -i (non-xpg) (mv -fi a b)" "$MV -fi" "a b" "a"
507 exp_retain "XPG4 mv last -n wins (mv -in a b)" "$XMV -in" "a b"
508 exp_retain "XPG4 mv last -n wins (mv -fn a b)" "$XMV -fn" "a b"
509 exp_retain "XPG4 mv last -n wins (mv -ifn a b)" "$XMV -ifn" "a b"
510 exp_retain "XPG4 mv last -n wins (mv -fifn a b)" "$XMV -fifn" "a b"
511 exp_pass "XPG4 mv last -f wins (mv -nf a b)" "$XMV -nf" "a b" "a"
512 exp_pass "XPG4 mv last -f wins (mv -if a b)" "$XMV -if" "a b" "a"
513 exp_pass "XPG4 mv last -f wins (mv -fif a b)" "$XMV -fif" "a b" "a"
514 exp_pass "XPG4 mv last -f wins (mv -nif a b)" "$XMV -nif" "a b" "a"
523 exp_pass "XPG4 cp -i no normal file (cp -i a b)" "$XCP -i" "a b" "b" \
525 exp_pass "XPG4 cp -i yes normal file (cp -i a b)" "$XCP -i" "a b" "a" "yes"
526 exp_pass "cp -i clobbers normal file regardless (cp -i a b)" "$CP -i" "a b" \
529 exp_pass "XPG4 mv -i no normal file (mv -i a b)" "$XMV -i" "a b" "b" \
531 exp_pass "XPG4 mv -i yes normal file (mv -i a b)" "$XMV -i" "a b" "a" "yes"
532 exp_pass "mv -i clobbers normal file regardless (mv -i a b)" "$MV -i" "a b" \
535 exp_pass "XPG4 ln -i no normal file (ln -i a b)" "$XLN -i" "a b" "b" \
537 exp_pass "XPG4 ln -i yes normal file (ln -i a b)" "$XLN -i" "a b" "a" "yes"
538 exp_pass "ln -i clobbers normal file regardless (ln -i a b)" "$LN -i" "a b" \
541 exp_pass "XPG4 cp -i yes beats -n normal file (cp -ni a b)" "$XCP -ni" "a b" \
543 exp_pass "cp -i beats -n (cp -ni a b)" "$CP -ni" "a b" "a" "cat /dev/zero"
545 exp_pass "XPG4 mv -i beats -n (mv -ni a b)" "$XMV -ni" "a b" "a" "yes"
546 exp_pass "mv -i beats -n (mv -ni a b)" "$MV -ni" "a b" "a" "cat /dev/zero"
547 exp_pass "XPG4 mv -i beats -f (mv -fi a b)" "$XMV -fi" "a b" "a" "yes"
549 exp_pass "XPG4 ln -fi no normal file (ln -fi a b)" "$XLN -fi" "a b" "b" \
551 exp_pass "XPG4 ln -fi yes normal file (ln -fi a b)" "$XLN -fi" "a b" "a" "yes"
552 exp_pass "ln -fi clobbers normal file regardless (ln -fi a b)" "$LN -fi" \
555 exp_pass "XPG4 ln -sfi no normal file (ln -sfi a b)" "$XLN -sfi" "a b" "b" \
557 exp_pass "XPG4 ln -sfi yes normal file (ln -sfi a b)" "$XLN -sfi" "a b" "a" \
559 exp_pass "ln -sfi clobbers normal file regardless (ln -sfi a b)" "$LN -sfi" \
566 exp_dir "cp multi-file" "$CP" "a b dir" 0 "dir/a" "b"
567 exp_fail "cp multi-file with socket fails" "$CP" "a b uds dir"
568 exp_fail "cp multi-file with noperms fails" "$CP" "a b c dir"
569 exp_dir "cp multi-file -n" "$CP -n" "a b dir" 0 "dir/a" ""
570 exp_dir "XPG4 cp multi-file -i yes" "$XCP -i" "a b dir" 0 "dir/a" "b" "yes"
571 exp_dir "XPG4 cp multi-file -i no" "$XCP -i" "a b dir" 0 "dir/a" "" \
573 exp_dir "cp multi-file -i clobbers anyways" "$CP -i" "a b dir" 0 "dir/a" "b" \
576 exp_dir "ln multi-file" "$LN" "a b dir" 2
577 exp_fail "ln multi-file with door fails" "$LN" "a door dir"
578 exp_dir "ln multi-file with socket works" "$LN" "a uds dir" 0 "dir/a dir/uds" ""
579 exp_dir "ln multi-file with noperms works" "$LN" "a c dir" 0 "dir/a dir/c" ""
580 exp_dir "ln multi-file -f" "$LN -f" "a b dir" 0 "dir/a" "b"
581 exp_dir "XPG4 ln multi-file -i yes" "$XLN -i" "a b dir" 0 "dir/a" "b" "yes"
582 exp_dir "XPG4 ln multi-file -i no" "$XLN -i" "a b dir" 0 "dir/a" "" \
584 exp_dir "ln multi-file -i clobbers anyways" "$LN -i" "a b dir" 0 "dir/a" "b" \
587 exp_dir "ln -s multi-file" "$LN -s" "a b dir" 2
588 exp_dir "ln -s multi-file with door works" "$LN -s" "a door dir" 0
589 exp_dir "ln -s multi-file with socket works" "$LN -s" "a uds dir" 0 \
591 exp_dir "ln -s multi-file with noperms works" "$LN -s" "a c dir" 0 \
593 exp_dir "ln -s multi-file -f" "$LN -s -f" "a b dir" 0 "dir/a" "b"
594 exp_dir "XPG4 ln -s multi-file -i yes" "$XLN -s -i" "a b dir" 0 "dir/a" "b" \
596 exp_dir "XPG4 ln -s multi-file -i no" "$XLN -s -i" "a b dir" 0 "dir/a" "" \
598 exp_dir "ln -s multi-file -i clobbers anyways" "$LN -s -i" "a b dir" 0 "dir/a" \
601 exp_dir "mv multi-file" "$MV" "a b c fifo door uds symlink dangle dir" 0 \
603 exp_dir "mv -n multi-file" "$MV -n" "a b c fifo door uds symlink dangle dir" 0 \
605 exp_dir "mv -f multi-file" "$MV -f" "a b c fifo door uds symlink dangle dir" 0 \
607 exp_dir "mv -i multi-file clobbers" "$MV -i" \
611 exp_dir "XPG4 mv -i multi-file no" "$XMV -i" \
615 exp_dir "XPG4 mv -i multi-file yes" "$XMV -i" \