linux git-shell,linux – 使用git-shell的自定义命令

如何为git-shell创建自定义命令?根据documentation:

When -c is given, the program executes non-interactively;

can be one of git receive-pack, git upload-pack, git

upload-archive, cvs server, or a command in COMMAND_DIR. The shell is

started in interactive mode when no arguments are given; in this case,

COMMAND_DIR must exist, and any of the executables in it can be

invoked.

但是,我不确定我是否正确理解这一点.我创建了一个名为gituser的用户,并将/usr/bin/git-shell作为shell.我创建了一个名为git-shell-commands的目录,并在其中放入了一个名为“testy”的脚本,但我无法通过git-shell运行它.

这是我正在尝试从另一台机器:

$ssh gituser@server.com testy

fatal: unrecognized command 'testy'

请注意,git-shell正在运行,并且响应,它无法找到我的自定义命令.

以下是脚本:

:/home/gituser/git-shell-commands# ls -l -a

total 12

drwxr-xr-x 2 gituser gituser 4096 Jan 22 17:35 .

drwxr-xr-x 4 gituser gituser 4096 Jan 22 13:57 ..

-rwxr-xr-x 1 gituser gituser 26 Jan 22 13:58 testy

:/home/gituser/git-shell-commands# ./testy

hello!

:/home/sodigit/git-shell-commands# cat testy

echo "hello!"

我究竟做错了什么?如何使用git-shell运行自定义命令?

解决方法:

事实证明,这个功能已经在git 1.7.4中引入.我正在使用debian squeeze,它包含一个旧版本的git,所以这就是为什么它不起作用.

如果您遇到此问题,请检查您的git版本.

但是,从git 1.7.10开始,自定义命令仅在交互模式下工作,而不在-c中工作.我没有尝试过最新的git,所以这个问题可能与软件版本无关.

标签:git,shell,linux,ssh

来源: https://codeday.me/bug/20190517/1123324.html