简体   繁体   English

OSX触摸命令-损坏?

[英]OSX Touch Command — Broken?

This feels like a silly question, but my touch command seems to have broken. 这似乎是一个愚蠢的问题,但我的touch命令似乎已中断。 Trying to create the ~/.bash_profile file using the command: touch ~/.bash_profile and seeing the following when I send the command: -bash: touch: No such file or directory. 尝试使用以下命令创建~/.bash_profile文件: touch ~/.bash_profile并在发送命令时看到以下内容: -bash: touch: No such file or directory. I've search quite a bit for an answer but haven't found the same problem so far. 我已经搜索了很多答案,但是到目前为止还没有发现相同的问题。 Can anyone assist? 有人可以协助吗? What exactly do I need to do in order to make the touch command work? 为了使触摸命令正常工作,我到底需要做什么?

You might like to run the touch command through OS X's equivalent of strace (I think that command exists on OS X, actually, although there appear to be others), go through the output and examine what errors are generated, if any. 您可能想通过OS X等效于strace方式运行touch命令(我认为该命令确实存在于OS X上,尽管似乎还有其他命令),然后检查输出并检查生成了什么错误(如果有)。 Pasting the output to a pastebin may also be a good idea. 将输出粘贴到pastebin也可能是一个好主意。

I think this is one of those instances where the call to strerror() inside touch 's C code is referencing an insane value of errno . 我认为这是在touch的C代码中对strerror()的调用引用了errno的疯狂值的情况之一。 (This is where all those " Error performing <X> : Success " messages come from. There was an error, but errno subsequently got set to 0 by a successful command before errno was captured and the error message printed.) (这是所有那些“ 执行错误<X>成功 ”。消息来自发生错误,但errno随后得到设置为0由一个成功的命令之前errno 。被捕获和错误信息印刷)

I have OS X Mavericks, and I use Kornshell, but I'll switch over to bash: 我有OS X Mavericks,并且使用Kornshell,但是我将切换到bash:

Let's try touching a non-existent file: 让我们尝试触摸一个不存在的文件:

$ touch foo

Nope. 不。 That worked. 那行得通。 Let's try touching a file you don't own: 让我们尝试触摸您不拥有的文件:

$ touch /usr/bin/true
touch true: Permission denied

Nope, that's what I expected and not what the OP got. 不,那是我的期望,而不是OP的期望。 Let's try with a symbolic link 让我们尝试一个符号链接

ln -s foo bar
touch bar

Nope, worked. 不,工作了。 Let's try it with a directory: 让我们尝试使用目录:

$ touch Applications

Nope, also worked. 不,也有效。

Try this: 尝试这个:

$ sum /usr/bin/touch
6205 9 /usr/bin/touch
$ file /usr/bin/touch
/usr/bin/touch: Mach-O 64-bit executable x86_64

If you're using Mavericks, I assume you should get the same results. 如果您使用的是Mavericks,我认为您应该获得相同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM