git checkout命令不会在csh脚本中获取文件名

时间:2014-08-25 05:03:34

标签: git shell

我制作了一个包含如下测试脚本的BBB (为方便起见,它用于备份和恢复临时文件)。

#!/bin/csh
if ($argv[1] == 1) then

cp e2fsprogs/old_e2fsprogs/blkid/blkid.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/blkid/blkidP.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/e2fsck.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/e2p/e2p.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/uuid/uuid.h  ~/bkup/Evac_BUSYBOX_
cp e2fsprogs/old_e2fsprogs/uuid/uuidP.h  ~/bkup/Evac_BUSYBOX_
cp include/libbb.h  ~/bkup/Evac_BUSYBOX_
cp include/platform.h  ~/bkup/Evac_BUSYBOX_
cp scripts/kconfig/lxdialog/dialog.h  ~/bkup/Evac_BUSYBOX_

else if ($argv[1] == 2) then

git checkout e2fsprogs/old_e2fsprogs/blkid/blkid.h
git checkout e2fsprogs/old_e2fsprogs/blkid/blkidP.h
git checkout e2fsprogs/old_e2fsprogs/e2fsck.h
git checkout e2fsprogs/old_e2fsprogs/e2p/e2p.h
git checkout e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
git checkout e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h
git checkout e2fsprogs/old_e2fsprogs/uuid/uuid.h
git checkout e2fsprogs/old_e2fsprogs/uuid/uuidP.h
git checkout include/libbb.h
git checkout include/platform.h
git checkout scripts/kconfig/lxdialog/dialog.h

else if ($argv[1] == 3) then

cp ~/bkup/Evac_BUSYBOX_/blkid.h e2fsprogs/old_e2fsprogs/blkid/blkid.h
cp ~/bkup/Evac_BUSYBOX_/blkidP.h e2fsprogs/old_e2fsprogs/blkid/blkidP.h
cp ~/bkup/Evac_BUSYBOX_/e2fsck.h e2fsprogs/old_e2fsprogs/e2fsck.h
cp ~/bkup/Evac_BUSYBOX_/e2p.h e2fsprogs/old_e2fsprogs/e2p/e2p.h
cp ~/bkup/Evac_BUSYBOX_/ext2fs.h e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h
cp ~/bkup/Evac_BUSYBOX_/kernel-jbd.h e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h
cp ~/bkup/Evac_BUSYBOX_/uuid.h e2fsprogs/old_e2fsprogs/uuid/uuid.h
cp ~/bkup/Evac_BUSYBOX_/uuidP.h e2fsprogs/old_e2fsprogs/uuid/uuidP.h
cp ~/bkup/Evac_BUSYBOX_/libbb.h include/libbb.h
cp ~/bkup/Evac_BUSYBOX_/platform.h include/platform.h
cp ~/bkup/Evac_BUSYBOX_/dialog.h scripts/kconfig/lxdialog/dialog.h

endif

当我运行BBB 2时,它给了我

-------------------------------------
error: pathspec 'e2fsprogs/old_e2fsprogs/blkid/blkid.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/blkid/blkidP.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/e2fsck.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/e2p/e2p.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/uuid/uuid.h' did not match any file(s) known to git.
error: pathspec 'e2fsprogs/old_e2fsprogs/uuid/uuidP.h' did not match any file(s) known to git.
error: pathspec 'include/libbb.h' did not match any file(s) known to git.
error: pathspec 'include/platform.h' did not match any file(s) known to git.
error: pathspec 'scripts/kconfig/lxdialog/dialog.h' did not match any file(s) known to git.

但是当我直接在shell提示符下运行git checkout命令时,它运行正常。 什么可能是错的?

1 个答案:

答案 0 :(得分:0)

确保在运行脚本时正确设置了当前目录。