| 1 | #!/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="basic 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 | touch rename_basic.{1..3} |
| 28 | $TS_CMD_RENAME --verbose basic test rename_basic.? >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 29 | |
| 30 | for i in rename_basic.?; do |
| 31 | echo "what is $i doing here?" >> $TS_OUTPUT |
| 32 | done |
| 33 | for i in rename_test.{1..3}; do |
| 34 | if [ ! -f $i ]; then |
| 35 | echo "file $i is missing" >> $TS_OUTPUT |
| 36 | else |
| 37 | rm -f $i |
| 38 | fi |
| 39 | done |
| 40 | |
| 41 | |
| 42 | touch rename_all\ file\ with\ spaces.{1..3} |
| 43 | $TS_CMD_RENAME --verbose --all ' ' '_' rename_all*.? >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 44 | |
| 45 | for i in rename_all*\ *.?; do |
| 46 | echo "what is $i doing here?" >> $TS_OUTPUT |
| 47 | done |
| 48 | for i in rename_all_file_with_spaces.{1..3}; do |
| 49 | if [ ! -f $i ]; then |
| 50 | echo "file $i is missing" >> $TS_OUTPUT |
| 51 | else |
| 52 | rm -f $i |
| 53 | fi |
| 54 | done |
| 55 | |
| 56 | touch rename_zz_last_{z,z{,z{,z}}}.{x..z} |
| 57 | $TS_CMD_RENAME --verbose --last zz AAzzBB rename_zz_last_* >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 58 | for i in rename_AAzzBB_last_z.x rename_AAzzBB_last_z.y rename_AAzzBB_last_z.z \ |
| 59 | rename_zz_last_AAzzBB.x rename_zz_last_AAzzBB.y rename_zz_last_AAzzBB.z \ |
| 60 | rename_zz_last_zAAzzBB.x rename_zz_last_zAAzzBB.y rename_zz_last_zAAzzBB.z ; do |
| 61 | if [ ! -f $i ]; then |
| 62 | echo "file $i is missing" >> $TS_OUTPUT |
| 63 | else |
| 64 | rm -f $i |
| 65 | fi |
| 66 | done |
| 67 | for i in rename*last* ; do |
| 68 | echo "what is $i doing here?" >> $TS_OUTPUT |
| 69 | done |
| 70 | |
| 71 | touch rename_all_empty |
| 72 | $TS_CMD_RENAME --verbose --all '' _ rename_all_empty >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 73 | rm -f _r_e_n_a_m_e___a_l_l___e_m_p_t_y_ |
| 74 | |
| 75 | mkdir rename_dir |
| 76 | $TS_CMD_RENAME --verbose dir new_dir rename_dir/ >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 77 | rmdir rename_new_dir |
| 78 | |
| 79 | ts_finalize |