OSX Touch Command -- Broken? - macos

This feels like a silly question, but my touch command seems to have broken. 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. 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. Pasting the output to a pastebin may also be a good idea.
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. (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.)

I have OS X Mavericks, and I use Kornshell, but I'll switch over to 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. 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.

Related

Why Can't My Xcode Project Folder Be Found in Terminal?

I am trying to use CocoaPods with my Xcode project -- Study Hall -- but when I try to locate the project on my desktop I get an error.
I have done the following,
$ ls
$ cd Desktop
$ ls
$ cd Study Hall
I expected for the Xcode project to come up on the Terminal but instead it gives me the error:
-bash: cd: Study: No such file or directory.
Why is this happening and how can I get it to function properly? This is actually my first time installing CocoaPods and using the Terminal so it is really confusing for me.
Try this:
$ cd Study\ Hall
You probably forgot to escape the space in the middle. Otherwise the terminal does not know if this should be treated as two parameters (Study + Hall) divided with a space or one parameter ("Study Hall") where the space is part of the name

-bash: ≈: command not found (OS X Terminal Error), How to Fix?

Whenever I start up Terminal on my Macbook Air, I get this message:
-bash: ≈: command not found
How do I fix this error? I'm running Mavericks version 10.9.4 if that helps at all.
EDIT: Fixed this error by using the bash -x method, found out it was a random '≈' character left in ~/.profile that needed to be deleted. Thanks for the answers :)
To debug you can try this:
bash -x -l
(the -l might not be needed).
I definitely agree with Barmar, there is something in your bash startup scripts.
There is not a great way to do this, but here is the protocol to remedy it.
Confirm it is your bash profile by first killing the process with a control + C if it is hung. Then do a source ~/.bash_profile and see if you get that same error.
Backup your bash profile cp ~/.bash_profile bashprofile.txt
Then comment out part of your bash profile. With text wrangler you can do a command + slash.
Save, then do a source ~/.bash_profile and see if the error still prints.
Repeat with different areas of the script until you have isolated the infected region.

How to get Terminal on OSX to start up clearly?

I am new to Mac OSX. Once after i typed export command in terminal, each time i start up the terminal, two messages show up:
-bash: export: '=': not a valid identifier
-bash: export: `:/Users/Li/File/Java/TStream': not a valid identifier
I know that clear and command+k can got a clean screen. But I just want to start up with a clean terminal.
Go to your terminal and type the
clear
command. This should clear your screen. Maybe what you're looking for is a way to have bash run that each time. If so, cd to your home directory:
cd ~
then edit the file called .bash_profile , or maybe .bashrc
On the last line write the word 'clear' without quotes, then save. This file runs when bash starts up, and the last thing it will do, therefore, is clear the screen.
For more info, checkout: this
EDIT:
Incidentally, I just realized you might want to clear the error. When you open up your .bashrc file, see if you can find a line that resembles the error you're getting, then comment it out.

PATH variable when calling make from XCode

For an iPad application I need to transform some CoffeeScript files into JavaScript files before bundling them with the application.
I tried to add a Makefile to my XCode project with the following code:
MANUAL_ROOT=IOS12BSH/manual
SCRIPTS_ROOT=$(MANUAL_ROOT)/scripts
COFFEE_SOURCES=$(SCRIPTS_ROOT)/*.coffee $(SCRIPTS_ROOT)/guides/*.coffee
JAVASCRIPT_TARGETS=$(COFFEE_SOURCES:.coffee=.js)
all: build
build: coffeescript
clean: clean_coffeescript
coffeescript: $(JAVASCRIPT_TARGETS)
clean_coffeescript:
rm -f $(JAVASCRIPT_TARGETS)
$(JAVASCRIPT_TARGETS): $(COFFEE_SOURCES)
coffee -c $(COFFEE_SOURCES)
Running this Makefile from the shell works without problems. However, after I added the Makefile as a target in XCode, I ran into problems.
The following error was produced by the Makefile:
coffee -c IOS12BSH/manual/scripts/*.coffee IOS12BSH/manual/scripts/guides/*.coffee
/bin/sh: coffee: command not found
make: *** [IOS12BSH/manual/scripts/*.js] Error 127
Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2
That is strange, as the coffee command is installed on my machine (it is installed under /opt/local/bin/coffee and /opt/local/bin is added to my $PATH in ~/.profile).
So I added an echo $(PATH) to my Makefile and it seems that the $PATH is different, when the Makefile is executed by XCode. XCode does not seem to read the settings from ~/.profile and therefore /opt/local/bin is not in $PATH.
What is the reason for this and how can I fix this, so that the coffee command is found?
Well, it seems that programs started via the Dock or Spotlight do not execute .profile and therefore $PATH is not set correctly.
So one way would be to set the $PATH in ~/.MacOSX/environments.plist. That works then apparently, but you will need a restart before it works.
Another way is to start XCode always from the command line with open projectfile.
This answer explains the problem in detail:
https://stackoverflow.com/a/14285335/751061
What ended up working best for me is just to launch Xcode from the command line.
I wrote a simple bash script that looks like:
source ~/.bash_profile # This is the trick that gets us our environment variables.
open -a "Xcode"
And then I call it from an Applescript Application just to give it a bundle I could put on the dock:
do shell script "~/xcode_launcher"
Sourcing your profile is necessary in the bash script, because running a script from Applescript doesn't ever source from a profile, so you still wouldn't have your default environment variables.
SAme thing with ant command. It works on terminal, not if Xcode have to do it. Only way to got it work: sudo open project.xcodeproj in terminal.

Mac OS: /usr/bin/env: bad interpreter: Operation not permitted

I'm trying to run this script on Mac OS 10.7 (Lion) and I'm getting the error:
$ bbcolors
-bash: /usr/local/bin/bbcolors: /usr/bin/env: bad interpreter: Operation not permitted
I've successfully run this script on other Macs of mine. It's just this script downloaded and unmodified from Daring Fireball.
I found this person with a very similar problem but the accepted answer was that the filesystem had a 'noexe' option on mount. I'm pretty sure that's not the case for me because I've just got it in /usr/local/bin/ and other stuff in there works fine (it also doesn't run from other places or as other users including root).
$ which bbcolors
/usr/local/bin/bbcolors
$ ls -l /usr/local/bin/bbcolors
-rwxr-xr-x# 1 nick staff 9751 Mar 30 19:09 /usr/local/bin/bbcolors
It's a Perl script not a compiled binary, not that that should matter. Here's some extra info for what it's worth:
$ cat /usr/local/bin/bbcolors |head -n 1
#!/usr/bin/env perl
$ which perl
/usr/bin/perl
$ env | grep PATH
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Did you happen to open/save the file in TextEdit?
That can introduce filesystem metadata (quarantine attribute) leading to the symptom you describe.
Try:
xattr -l /usr/local/bin/bbcolors
and
xattr -d com.apple.quarantine /usr/local/bin/bbcolors
if you see the quarantine attribute.
pilcrow's answer is correct, however I draw your attention to the fact that if you are working with a disk image, the problem can be very confusing, as the com.apple.quarantine attribute seems to be inherited from the disk image file to the files inside (thanks to febeling at Apple dev forums for noticing that!).
To solve the problem, you have to remove the quarantine attribute from the disk image:
xattr -d com.apple.quarantine /path/to/disk/image
and then eject and remount the disk image. Then your files will be clean again.
I had resolved this issue.Open the command file with TextEdit then save it.
More Info:Resolved Operation not permitted
-bash: /usr/local/bin/bbcolors: /usr/bin/env: bad interpreter: Operation not permitted
Does /usr/bin/env exist? Can you run it? Run by itself it should dump your environment variables to stdout.
You can safely replace:
#!/usr/bin/env perl
With the full path to your perl binary of choice, e.g:
#!/usr/bin/perl
I ran into this after creating a shell script in BBEdit (CLI: bbedit ~/bin/foo). It seems that the macOS sandbox security feature automatically quarantines files modified by BBEdit — if the file is executable and is accessed by BBEdit in a certain way.
The fix is easy: Preferences > Application > Allow
https://www.barebones.com/support/bbedit/quarantine.html
1.delete "node_modules" folder
2.npm install

Resources