- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这最终成为路径问题。我在脚本的其他地方使用“路径”作为我的变量之一,但没有意识到这实际上编辑了环境变量 PATH。
原始问题:
我正在写一个批处理文件。在批处理文件中,我有以下内容:
FOR /F "tokens=*" %%a IN ('git branch -r') DO CALL :SOMELABEL %%a
EXIT
:SOMELABEL
git status
START /B /WAIT CMD /C git status
FOR /F "tokens=*" %%n IN ('git status') DO ECHO %%n
GOTO :EOF
'git status' 只是一个例子。 3 个 'git status' 命令中的每一个都返回“'git' 未被识别为内部或外部命令、可运行的程序或批处理文件。”
通常,这将是一个环境变量问题 (PATH),但它的独特之处在于第一个 git 命令有效(“git branch -r”)。我可能还有 5 个其他批处理文件也可以成功使用 git 命令。关于为什么后面的 git 命令在上面的代码中不起作用有什么想法吗?
如果是由于权限问题(比如在执行一个 git 命令时无法执行另一个 git 命令之类的事情),知道我如何使这个脚本工作(最好不必创建临时文件)吗?还是为第一个命令的输出制作一个临时文件是唯一的方法?
最佳答案
不过,这应该是一个 PATH
问题。
OP Lectrode确认:
It was a path issue.
I just realized that in my original script I was usingpath
for one of my variables.
I did not realize that was setting the environmentPATH
variable.Apparently git uses that "batch proxy" thing.
The command works when you changegit status
toCALL git status
.
原答案:
我刚刚成功测试了以下脚本,遵循“DOS Batch - Function Tutorial ”中描述的语法(并使用我安装的 'which' 命令 through gow ):
@echo off
echo.PATH=%PATH%
which git.exe
FOR /F "tokens=*" %%a IN ('git branch -r') DO CALL :myDosFunc %%a
call:myDosFunc
echo.&pause&goto:eof
:myDosFunc - here starts my function identified by it`s label
echo. with param %~1
which git.exe
git status
goto:eof
当在 Windows 上的 Git 存储库中执行时,它确实返回了:
C:\prog\git\tests\my_repo>..\c.bat
PATH=Z:\apps\git176\bin;...
Z:\apps\git176\bin\git.exe
with param origin/master
Z:\apps\git176\bin\git.exe
# On branch master
nothing to commit (working directory clean)
with param
Z:\apps\git176\bin\git.exe
# On branch master
nothing to commit (working directory clean)
所以它似乎有效。 (作为 pointed out by Magnus ,我不使用 exit
)
关于git - "' git ' is not recognized as an internal"blah blah 即使命令第一次运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9815223/
所以,当我在线程外创建“boxes”和“boxbound”变量时出现运行时错误,但是当我将它移动到线程内的 for 循环中时错误消失了,这可能是什么原因? void Flyscene::raytrac
在 SO 和其他博客的博客评论中,我注意到一些用户发布验证码的趋势,他们必须解决验证码才能让他们的帖子被接受。 他们这样做是为了帮助破解验证码的机器人吗? 如果是这样,是否有办法以编程方式(服务器端)
我无法理解我可以从 Url.Content() 获得的好处ASP.NET MVC 中的方法。例如,您会看到 src='@Url.Content("~/Contents/Scripts/jQuery.j
这是什么意思。是不是因为我有两个不同的 .DBML 文件包含相同的数据库表? ... Error 343 The type 'mvc.Models.Bundle' already contains
之前我可以输入 R.id.exit 现在我必须输入 com.ramos.science.R.id.exit 为什么? 最佳答案 检查您的导入,确保 com.ramos.science.R 列在那里。
我有一个像这样的枚举: typedef NS_ENUM(int, name) { kAll, kFirstType, kSecondType }; 然后我做: if (type
我知道如何在 C# 4.0 中使用 dynamic,但是,我不确定如何获取一些东西并使其动态化(我的技术术语)。 例如,除了 ConfigurationManager.AppSettings["bla
如果 web/app.config 中不存在“blah”,ConfigurationManager.AppSettings["blah"] 会抛出异常吗? 最佳答案 不,它返回null。 关于.net
我目前有一个像这样定义一些变量的 block var slider_1 = document.querySelector('#slider_1'); var slider_2 = document
我正在学习一些教程,但有一行代码我不太理解: - (NSString *)rankAsString { return @[@"?",@"A",@"2",@"3",@"4",@"5",@"6",@"7"
如果我在某个网址...说 http://i.imgur.com/JcxmE.jpg它只是图像文件,当调用书签时,如何使窗口/div 出现在图像上?Instapaper 就是这样做的。到目前为止,我的书
我选择了第一列的几行,并使用 .values 和 as_matrix() 将其转换为 numpy 数组。 x1 = df.iloc[[1,3,4,64,34], 0] 数据帧中每个元素的维度是 (3,
这最终成为路径问题。我在脚本的其他地方使用“路径”作为我的变量之一,但没有意识到这实际上编辑了环境变量 PATH。 原始问题: 我正在写一个批处理文件。在批处理文件中,我有以下内容: FOR /F "
是否有一个 JavaScript 国际化库支持获取一组项目并根据区域设置将它们转换为语法正确的列表?我正在寻找能够处理以下输入的东西,如下所示的英语。 [foo, bar, blah] -> "foo
我将在 svg 元素上设置各种 css 样式,并认为我可以做类似的事情 d3.selectAll(".whatever") .style(function(d) { return {"color
我确定有一种更惯用的 ruby 方式来编写下面的代码: @var = obj['blah'] unless obj['blah'].nil? 我有很多事情要做(见下文),一定有更好的方法! @nu
有什么区别: [blah addObject:@"1"]; 和 [blah insertObject:@"0" atIndex:0]; ??? 我知道它们都用于 NSMutableArray。 最佳答
首先,一些激励人心的背景信息;我正在试验将错误代码(从函数返回)表示为超轻量级人类可读字符串而不是枚举整数的想法,如下所示: #include /** Ultra-lightweight type
在 section 2.2.2, "CSS and Sass" , 我被告知输入 image-url('delete.png')在我的萨斯。所以我有。 但是,它正在生成 CSS background-
我想要一个可以监听所有接口(interface)并为每个接口(interface)发布发现公告的可发现服务。我希望最终能够使用 tcp://0.0.0.0:0/blah 作为服务端点在配置文件中配置它
我是一名优秀的程序员,十分优秀!