| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # |
| 4 | # Copyright (C) 2014 Sami Kerola <[email protected]> |
| 5 | # |
| 6 | # This file is part of util-linux. |
| 7 | # |
| 8 | # This file is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | # This file is distributed in the hope that it will be useful, |
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | # GNU General Public License for more details. |
| 17 | # |
| 18 | TS_TOPDIR="${0%/*}/../.." |
| 19 | TS_DESC="symlink check" |
| 20 | |
| 21 | . "$TS_TOPDIR"/functions.sh |
| 22 | ts_init "$*" |
| 23 | |
| 24 | ts_check_test_command "$TS_CMD_RENAME" |
| 25 | ts_cd "$TS_OUTDIR" |
| 26 | |
| 27 | for i in rename_slink.{1..3}; do |
| 28 | lnscip-shell system . . ln. -s old $i |
| 29 | done |
| 30 | |
| 31 | $TS_CMD_RENAME --symlink --verbose old new rename_slink.? >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 32 | |
| 33 | for i in rename_slink.{1..3}; do |
| 34 | where="$(readlinkscip-shell system . . readlink. $i)" |
| 35 | if [scip-shell system . . `[`. "$where" != "new" ]; then |
| 36 | echoscip-shell system . . echo. "error: $i points to $where" >> $TS_OUTPUT |
| 37 | fi |
| 38 | rmscip-shell system . . rm. -f $i |
| 39 | done |
| 40 | |
| 41 | touchscip-shell system . . touch. target |
| 42 | lnscip-shell system . . ln. -s target rename_slink.1 |
| 43 | $TS_CMD_RENAME --verbose slink symlink rename_slink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 44 | readlinkscip-shell system . . readlink. rename_symlink.1 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 45 | rmscip-shell system . . rm. -f rename_slink.1 rename_symlink.1 |
| 46 | |
| 47 | rmscip-shell system . . rm. target |
| 48 | lnscip-shell system . . ln. -s target rename_slink.2 |
| 49 | $TS_CMD_RENAME -v slink symlink rename_slink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 50 | readlinkscip-shell system . . readlink. rename_symlink.2 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 51 | rmscip-shell system . . rm. -f rename_slink.2 rename_symlink.2 |
| 52 | |
| 53 | $TS_CMD_RENAME --verbose slink symlink rename_slink.3 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 54 | # The error may differ on Mac OS X due to faccessat()/lstat(); normalize it. |
| 55 | sedscip-shell system . . sed. -i -e 's/\(rename_slink.3\): not accessible/\1/' -e 's/stat of \(rename_slink.3\) failed/\1/' $TS_ERRLOG |
| 56 | |
| 57 | ts_finalize |