The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting.

Posts under Zsh tag

25 Posts
Sort by:
Post not yet marked as solved
1 Replies
28 Views
We have been trying to understand why the Mac OS Terminal, when invoked with open, does not pass along the environment variables. How to reproduce? Create a new file /tmp/example.sh #!/bin/sh echo "SAMPLE_ENV='$SAMPLE_ENV'" SAMPLE_ENV=123 open -a Terminal /tmp/example.command Only prints: SAMPLE_ENV='' Even when using SAMPLE_ENV=123 open --env SAMPLE_ENV=1234 -a Terminal /tmp/example.sh    it will only print SAMPLE_ENV='' We know for sure that this was working several years ago. Why was the feature removed or is this a bug? Any workaround? Is there a workaround on how to launch a script in a new Terminal Window while passing the environment variables correctly? Related https://stackoverflow.com/questions/69768133/react-native-envs-are-undefined-in-metro-bundlers-config-file-when-bundling/73036234
Posted
by
Post not yet marked as solved
0 Replies
122 Views
Hello everyone. The project I am working on is shifting from using CocoaPods to SPM and there is one "wrinkle" I'd like some advice on. The project has several framework projects containing code as well as the main app project. All of these make use of code generators (RSwift, Sourcery) at some point and these need to be run before the main build starts. The problem is that SPM builds do not support the concept of adding script phases so there appears to be no easy way to incorporate these shell tools into the builds. Particularly in the framework projects which are pure SPM packages and therefore do not have your typical project files and build phases. My question is - how to deal with shell based build phases in an SPM world? Currently we are adding these phases in the main app's build. However they are not run before the builds of the SPM dependencies so effectively we have to run the build twice to ensure the code is up to date.
Posted
by
Post marked as solved
1 Replies
184 Views
Working with a M1 Macbook Air, macos 12.4. Anytime I open a new terminal window or just a new tab, it takes a really long time till I can type. I have commented out my entire ~/.zshrc and when run for i in $(seq 1 10); do /usr/bin/time $SHELL -i -c exit; done directly in an open terminal window it says it finished in 0.1s. So it must be something macos is doing before zsh is even starting. PS: In the activity monitor I can only see a spike in kernel_task cpu usage when opening a new terminal
Posted
by
Post not yet marked as solved
0 Replies
171 Views
I need to create a script for checking a security posture of a machine using OPSWAT MetaAccess. They have a built-in check, however, according to them, they aren't able to check since macOS 10.13+. This seems to coordinate with a change other people have discussed on other forums where the following commands don't work anymore. OPSWAT does support checks via custom shell script and so I'm figuring out how to write that now. The scripts that don't work anymore: defaults read com.apple.screensaver idleTime defaults -currentHost read com.apple.screensaver idleTime defaults -currentHost read com.apple.screensaver askForPassword defaults read com.apple.screensaver askForPassword
Posted
by
Post not yet marked as solved
1 Replies
475 Views
We have a problem with curl. Under Big Sur, the command curl 'ftp://ftp.myserver/myPath/my File' -u 'myusername':'mypassword' properly downloads the file. Under Monterey, the same command throws an error: curl: (3) URL using bad/illegal format or missing URL Any advice, workaround etc. is highly appreciated. The behaviour is the same, whether the command is issued in Terminal, or as a shell script in a Applescript application created in XCode.
Posted
by
Post not yet marked as solved
1 Replies
422 Views
When i compile the c program with mysql i get the next error: ld: library not found for -lzstd clang: error: linker command failed with exit code 1 (use -v to see invocation) So i use the zstd (that i installed) directory link in my command line gcc parking.o -o parking.exe `mysql_config --libs` -L/opt/homebrew/Cellar/zstd/1.5.2/lib It creates the .exe but when i launch it i get How can i solve it ? Need help please.
Posted
by
Post not yet marked as solved
0 Replies
221 Views
I had a number of paths, aliases, customizations and such in my ZSH profile, but I opened up Terminal, today, and now the only thing in it is a path for SDKMAN. how could this have happened? can I restore my profile?
Posted
by
Post not yet marked as solved
0 Replies
217 Views
Whenever I am trying to run the command "dsconfigad -show", it is not returning anything. But I can see that I am connected to a domain in "enterprise connect". My Mac version is Monterey(version 12.2). Can anyone solve this issue. Thanks in advance.
Posted
by
Post not yet marked as solved
17 Replies
15k Views
Not really a "developer" question per se, but related to the Xcode developer tools as run on a new M1 Mac running Monterey (12.1). When running various tools, such as "opendiff" I receive the following error reported on stderr: objc[6599]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1e30deb90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108f7c2c8). One of the two will be used. Which one is undefined. objc[6599]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1e30debe0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108f7c318). One of the two will be used. Which one is undefined. I'm working on the assumption that two conflicting libraries have been installed that provide a definition for the same symbol, and (since the opendiff program loads and runs) that at least for now, both symbols are defined in a similar enough way that whichever one is actually loaded works. I was at first very confused because there is actually no file on my system with the name /usr/lib/libauthinstall.dylib While this makes the error message rather confusing, I found this thread https://developer.apple.com/forums/thread/692383 that makes clear that many of the files in /usr/lib in an earlier part of the release process are amalgamated, and I assume that libauthinstall.dylib is one of these files. Given that this implies that the /usr/lib versions are likely the "more authoritative" versions, I am not actually sure why the directory /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework even exists -- I don't do any mobile development on this machine, so I assume that it came out of the setup, or possible from a migration of the user content from a machine running BigSur (content transferred using TimeMachine). Does anyone have any ideas regarding: (a) how this came about (as it appears that both sources are installed by Apple), and (b) how I can remove the conflict. I'm using opendiff in a project workflow and really don't want to see the workflow polluted with spurious error messages, not to mention the fragility of not being able to control which symbol these tools are actually using. Thanks in advance for any thoughts. EDIT: There are a number of posts around the 'net linking this error with "homebrew". I believe that this is at least partially a red herring, because: a) I don't use homebrew (though I do use MacPorts) -- I avoid hombrew largely because of its plan to play in /usr while MacPorts keeps everything well out of the way in /opt b) both of the named sources are from Apple.
Posted
by
Post not yet marked as solved
0 Replies
397 Views
I have some shell scripts that are needed to run on the Build Phase of my iOS App, but all of then keeps getting killed when trying to run. For example with SwiftLint: /Users/vinicius/Library/Developer/Xcode/DerivedData/MyProject-somerandomstuff/Build/Intermediates.noindex/MyProject.build/Debug-iphonesimulator/MyProject.build/Script-BE4377BE84BF95B2A0F6A35B.sh: line 2: 44634 Killed: 9        "${PODS_ROOT}/SwiftLint/swiftlint" autocorrect I was thinking that could be related to some lack of permission, but I can't really identify if it really is, since it's executing the files. Do you have any idea?
Posted
by
Post not yet marked as solved
9 Replies
1.8k Views
I have a command line tool that zsh refuses to run when built for Apple Silicon or as a univerisal binary (the specific message is zsh: killed TOOL_NAME). I can only get it to run if I build it exclusively for Intel/Rosetta. Running/debugging from within Xcode works fine for any architecture. The tool is a very simple C/C++ unix command-line tool; it doesn't have any external dependencies beyond the C runtime and the C++ STL. I suspect something in code signing is going awry, but I've tried various team and certificate combinations without any luck. I've also tried enabling/disabling the app sandbox, also without any luck. (The app is not for distribution so it doesn't really need to be code signed at all.) Any suggestions?
Posted
by
dwn
Post not yet marked as solved
5 Replies
13k Views
Hi Guys, I am using the new Apple M1 Max and macOS Monterey, I am trying to install cocoa pod but getting errors like below. I tried to fix it with help of StackOverflow and many ways but no luck. Please help to resolve this issue. ERROR: While executing gem ... (Gem::FilePermissionError)   You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
Posted
by
Post not yet marked as solved
0 Replies
310 Views
I am trying to open Facebook Messenger on my app. It opens so far as I can see my contacts, but before I can see my messages it closes. Then Terminal gives me this message: Last login: Fri Dec 3 08:49:11 on ttys001 /Applications/Messenger.app/Contents/MacOS/Messenger ; exit; [myusername]@iMac ~ % /Applications/Messenger.app/Contents/MacOS/Messenger ; exit; zsh: abort /Applications/Messenger.app/Contents/MacOS/Messenger Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process completed] Any suggestions how to open this app.
Posted
by
Post not yet marked as solved
1 Replies
378 Views
Paths in /etc/paths.d are not expanded for all shells. dotnet adds a /etc/paths.d/dotnet-cli-tools file that contains ~/.dotnet/tools The ~/.dotnet/tools folder is used for tools that are 'global' across all projects for the same user. The tilde is not expanded for zsh and executables installed to ~/.dotnet/tools will not be found via the PATH. $HOME/dotnet/tools is also not expanded. (There appears to be a difference with bash. bash does seem to expand the tilde but doesn't expand variables.) The man page for path_helper says Files in these directories should contain one path element per line. The /etc/paths.d mechanism is great. Keeping installers out of a user's .profile/.zprofile/.zshrc/etc files is very helpful. But user home directory paths for the current user are not supported (at least not consistently across all shells) in the current implementation of path_helper and paths.d. Not expanding paths might be by design or by omission but adding support for paths in the current user home would be useful.
Posted
by
Post not yet marked as solved
3 Replies
914 Views
I've just bought a new MacBook Pro M1, and restored everything from my old Intel MacBook Pro using a Time Machine backup. It was a pretty smooth process, a few glitches such as needing to re-download certain apps to get the M1 version (e.g. Android Studio). One thing that I've noticed, and I don't know whether this is a Monterey thing or an M1 thing but as part of my day-to-day development work, I maintain various .sh files for building projects on different platforms. I have found that as soon as I edit and save an existing .sh file using TextEdit, it then sets the quarantine bit on the file and prevents it running from inside Zsh: zsh: operation not permitted: ./test.sh xattr yields the following: xattr ./test.sh  com.apple.TextEncoding com.apple.lastuseddate#PS com.apple.macl com.apple.metadata:kMDLabel_pjtfm5adga5rvjv2xmgkyqjwmq com.apple.quarantine This is incredibly annoying and I can't believe it is by design - this is not a file that has been downloaded from the Internet, it's my own file. Why can't I edit it using TextEdit? I do not get the same problem when I edit and save using Sublime Text, as one example, so what's with TextEdit doing that?
Posted
by
Post not yet marked as solved
2 Replies
498 Views
Hi! I am new to OSX Shell Script and am trying to work my way into it. I don't get the expected outcome with the following snippet of my script code and I have no idea, why. I read most of the Apple Shell Script Pimer and googled a lot about it, but to no avail. I want to check the current username against some given usernames and set the value of a variable depending on the outcome. I used awk inside the shell script to get this done, but for some reason the for loop inside the awk part seems to change the value of the current username with every loop. This is the code: #!/bin/zsh awk -v u=$USER 'BEGIN {        print "Username outside loop is " u;       count[0] = "Anton";       count[1] = "Bert";       count[2] = "Carl";                                 for ( c_num in count ) {             print "Username inside loop is " u;             print "Compare to "count[c_num];                                                 if (u = count[c_num]) {                   test_var = "X";             } else {                   test_var = "Y";             }             print test_var;       } }' And this is what I get after I run it in terminal: Username outside loop is Zac Username inside loop is Zac Compare to Carl X Username inside loop is Carl Compare to Anton X Username inside loop is Anton Compare to Bert X I don't see why 'u' is changed every loop. I'm thankful for every help / advice! Markus
Posted
by
Post not yet marked as solved
0 Replies
417 Views
For an IT department initiative, we have to remotely remove admin rights from a subset of M1 Macbook Air users. Their computers were set up manually with one original admin user account. After much research and testing, the admin rights removal portion of our scripting is working except for the original admin user account. A few niche online resources indicated this might possibly be due to M1's having a new type of user account called an owner. I also read that any secondary accounts after the initial one should have access to the OIK and OIC so we're confused why admin rights aren't getting removed from that original user when it works on other secondary accounts in multiple ways of testing. Any ideas or context surrounding this elusive new owner type of account, why the working script won't remove admin rights from that account but will for others, or if there's some missing info in order to accomplish this goal? We ideally would like to add an IT managed admin user and remove admin from the original user (current MDM does not support his inherently so we're getting creative.)
Posted
by
Post not yet marked as solved
2 Replies
558 Views
Script Example: sudo dscl . -create /Users/ITAdmin sudo dscl . -create /Users/ITAdmin UserShell /bin/bash sudo dscl . -create /Users/ITAdmin RealName ITAdmin sudo dscl . -create /Users/ITAdmin UniqueID 502 sudo dscl . -create /Users/ITAdmin PrimaryGroupID 20 sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Local/Users/ITAdmin sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Users/[ITuser] sudo dscl . -passwd /Users/ITAdmin [password] sudo dscl . -append /Groups/admin GroupMembership ITAdmin When using this locally or remotely, it works except the Home folder does not create or show up in the UI. After further testing, it does show up after an initial first time login. With our remote workforce and the secondary reasons for needing this script, we're trying to find a way to mimic a user login to add into our actual other script so that the home folder is created without actual end user interaction (won't be possible.) Or are there any other alternative ways to script a new admin user account? (Or a better place to ask this?) Thanks in advanced!
Posted
by
Post not yet marked as solved
0 Replies
322 Views
I created a VENV.Even though I hardcoded in JSON files the path and deleted in the gut the path for python of my venv.still my systems default python keeps running.I am stuck I cannot get my venv python to run even though It says on vs code in the bottom that it is selected.Kindly help.
Posted
by