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

54 Posts

Post

Replies

Boosts

Views

Activity

zsh for-loop erroneously expanding file extension
I've been using a bash for-loop for a bioinformatics project without problem until a few days ago, then it suddenly stopped working. I'm on OSX V12.1. Command: for FILE in ls *.fasta do F=$(basename "$FILE".fasta) COMMAND -f "$F".input -o "$F".output done It's a very simple for-loop, but starting three days ago, it started iterating over the file extension and giving this error: File/Path Error: No such file: 'FILE.fasta.fasta' I'm not sure what the issue is. I've tried unsetting both F and FILE, but that hasn't worked. I've done the old 'turn everything off and back on', which also didn't work. I've done my best to scour the internet for a solution, but I may be missing the correct terminology because I've come up empty.
0
0
1.5k
Aug ’22
Terminal does not receive Environment Variables
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
2
0
2.2k
Jul ’22
Recommendations for adding script phases to a build with SPM
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.
0
0
1.6k
Jun ’22
Just updated to ZSH; Messenger won't open.
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.
1
0
1.2k
Jun ’22
Opening a new terminal window or tab is extremely slow
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
1
0
2.3k
Jun ’22
Shell Script to check password has been set to Immediately and what the screen saver time is set to
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
0
0
1.1k
Apr ’22
library libzstd is missing in mysql (macos monterey m1 pro)
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.
1
0
2.4k
Mar ’22
Build Phase scripts aren't running on XCode 13.2.1 and keeps failing
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?
0
0
1.1k
Jan ’22
Editing my own .sh file with TextEdit sets the quarantine bit, why?
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?
4
0
2.7k
Dec ’21
zsh: segmentation fault | using AHOY
Machine - MacBook Pro 13 with Apple M1 chip Hi team, Just wanted to get some help in sorting Ahoy installation on new MacBook Pro 13 with Apple M1 chip. I ran "brew install ahoy" but got a message saying "bottle not available" I have been able to build it from source and as per log below, it seems to have installed. But when I run any commands, I am getting a "zsh: segmentation fault ahoy help" error and unable to run any ahoy commands. NOTE: MacBook CONSOLE LOG added below. CONSOLE ERROR LOG - ++++++++++++++++++++++++++++++++++++++++ Process: ahoy [1840] Path: /opt/homebrew/*/ahoy Identifier: ahoy Version: ??? Code Type: X86-64 (Translated) Parent Process: zsh [1748] Responsible: Terminal [1746] User ID: 501 Date/Time: 2021-02-15 12:23:20.982 +1100 OS Version: macOS 11.2.1 (20D74) Report Version: 12 Anonymous UUID: D7AF3B6F-CFAB-F9ED-0E45-DC1AD1784827 Sleep/Wake UUID: 1689D6DE-2DD8-496C-AAC6-A6BE6699BBE9 Time Awake Since Boot: 6300 seconds Time Since Wake: 1500 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [1840] VM Regions Near 0x18:- __TEXT 1000000-125f000 [ 2428K] r-x/rwx SM=COW Application Specific Information: dyld2 mode Thread 0 Crashed: 0 runtime 0x00007ffdfff70bb0 0x7ffdfff5f000 + 72624 1 0x00000000010518fd runtime.bsdthread_register + 29 2 0x00000000010295d1 runtime.schedinit + 161 Thread 1:: com.apple.rosetta.exceptionserver 0 runtime 0x00007ffdfff61238 0x7ffdfff5f000 + 8760 1 runtime 0x00007ffdfff6b354 0x7ffdfff5f000 + 50004 2 runtime 0x00007ffdfff6c1f8 0x7ffdfff5f000 + 53752 Thread 0 crashed with ARM Thread State (64-bit): x0: 0x800000010000fb90 x1: 0x00000000010518a0 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x0000000000000000 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x000000c42000a020 x8: 0x00007ffdfffd4a00 x9: 0x00007ffdfffd4a08 x10: 0x0000000000000000 x11: 0x00000000ffffffff x12: 0x0000000000000000 x13: 0x00000000ffffffee x14: 0x0000000000000140 x15: 0x0000000000000100 x16: 0x000000000000016e x17: 0x0000000000000000 x18: 0x800000010000fb90 x19: 0x0000000100000000 x20: 0x00000000000007ff x21: 0x0000000100014fc0 x22: 0x00000002055eaac8 x23: 0x000000000150e224 x24: 0x00000000010243b0 x25: 0x00000000013022d0 x26: 0x00000000012f8cd8 x27: 0x0000000000000000 x28: 0x00000000010518fd fp: 0x00007ffdfff70b98 lr: 0x000000000150e254 sp: 0x000000010000fb90 pc: 0x00007ffdfff70bb0 cpsr: 0x80000000 far: 0x0000000000000018 esr: 0x92000006 Binary Images: 0x1000000 - 0x125efff + (???) 0x1014d3000 - 0x10156efff dyld (832.7.3) 0D4EA85F-7E30-338B-9215-314A5A5539B6 /usr/lib/dyld 0x7ffdfff5f000 - 0x7ffdfffd2fff +runtime (203.30) C98E75A6-BDC8-3D5C-B95B-6422005E96D8 /Library/Apple/*/runtime External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 4298 thread_create: 0 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=3972K resident=0K(0%) swapped_out_or_unallocated=3972K(100%) Writable regions: Total=150.7M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=150.7M(100%) VIRTUAL REGION REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Rosetta Arena 2048K 1 Rosetta Generic 584K 143 Rosetta IndirectBranch 32K 1 Rosetta JIT 128.0M 1 Rosetta Return Stack 20K 2 Rosetta Thread Context 20K 2 VM_ALLOCATE 528.5G 9 VM_ALLOCATE (reserved) 8K 2 reserved VM address space (unallocated) __DATA 488K 6 __DATA_CONST 32K 1 __LINKEDIT 492K 5 __TEXT 3516K 3 mapped file 4.7G 12 =========== ======= ======= TOTAL 533.3G 188 TOTAL, minus reserved VM space 533.3G 188
2
0
4.9k
Nov ’21
zsh for-loop erroneously expanding file extension
I've been using a bash for-loop for a bioinformatics project without problem until a few days ago, then it suddenly stopped working. I'm on OSX V12.1. Command: for FILE in ls *.fasta do F=$(basename "$FILE".fasta) COMMAND -f "$F".input -o "$F".output done It's a very simple for-loop, but starting three days ago, it started iterating over the file extension and giving this error: File/Path Error: No such file: 'FILE.fasta.fasta' I'm not sure what the issue is. I've tried unsetting both F and FILE, but that hasn't worked. I've done the old 'turn everything off and back on', which also didn't work. I've done my best to scour the internet for a solution, but I may be missing the correct terminology because I've come up empty.
Replies
0
Boosts
0
Views
1.5k
Activity
Aug ’22
Terminal does not receive Environment Variables
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
Replies
2
Boosts
0
Views
2.2k
Activity
Jul ’22
Recommendations for adding script phases to a build with SPM
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.
Replies
0
Boosts
0
Views
1.6k
Activity
Jun ’22
Just updated to ZSH; Messenger won't open.
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.
Replies
1
Boosts
0
Views
1.2k
Activity
Jun ’22
Opening a new terminal window or tab is extremely slow
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
Replies
1
Boosts
0
Views
2.3k
Activity
Jun ’22
Shell Script to check password has been set to Immediately and what the screen saver time is set to
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
Replies
0
Boosts
0
Views
1.1k
Activity
Apr ’22
library libzstd is missing in mysql (macos monterey m1 pro)
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.
Replies
1
Boosts
0
Views
2.4k
Activity
Mar ’22
My ~/.zshrc Was Overwritten
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?
Replies
0
Boosts
0
Views
945
Activity
Feb ’22
Build Phase scripts aren't running on XCode 13.2.1 and keeps failing
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?
Replies
0
Boosts
0
Views
1.1k
Activity
Jan ’22
Editing my own .sh file with TextEdit sets the quarantine bit, why?
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?
Replies
4
Boosts
0
Views
2.7k
Activity
Dec ’21
zsh: segmentation fault | using AHOY
Machine - MacBook Pro 13 with Apple M1 chip Hi team, Just wanted to get some help in sorting Ahoy installation on new MacBook Pro 13 with Apple M1 chip. I ran "brew install ahoy" but got a message saying "bottle not available" I have been able to build it from source and as per log below, it seems to have installed. But when I run any commands, I am getting a "zsh: segmentation fault ahoy help" error and unable to run any ahoy commands. NOTE: MacBook CONSOLE LOG added below. CONSOLE ERROR LOG - ++++++++++++++++++++++++++++++++++++++++ Process: ahoy [1840] Path: /opt/homebrew/*/ahoy Identifier: ahoy Version: ??? Code Type: X86-64 (Translated) Parent Process: zsh [1748] Responsible: Terminal [1746] User ID: 501 Date/Time: 2021-02-15 12:23:20.982 +1100 OS Version: macOS 11.2.1 (20D74) Report Version: 12 Anonymous UUID: D7AF3B6F-CFAB-F9ED-0E45-DC1AD1784827 Sleep/Wake UUID: 1689D6DE-2DD8-496C-AAC6-A6BE6699BBE9 Time Awake Since Boot: 6300 seconds Time Since Wake: 1500 seconds System Integrity Protection: enabled Crashed Thread: 0 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [1840] VM Regions Near 0x18:- __TEXT 1000000-125f000 [ 2428K] r-x/rwx SM=COW Application Specific Information: dyld2 mode Thread 0 Crashed: 0 runtime 0x00007ffdfff70bb0 0x7ffdfff5f000 + 72624 1 0x00000000010518fd runtime.bsdthread_register + 29 2 0x00000000010295d1 runtime.schedinit + 161 Thread 1:: com.apple.rosetta.exceptionserver 0 runtime 0x00007ffdfff61238 0x7ffdfff5f000 + 8760 1 runtime 0x00007ffdfff6b354 0x7ffdfff5f000 + 50004 2 runtime 0x00007ffdfff6c1f8 0x7ffdfff5f000 + 53752 Thread 0 crashed with ARM Thread State (64-bit): x0: 0x800000010000fb90 x1: 0x00000000010518a0 x2: 0x0000000000000000 x3: 0x0000000000000000 x4: 0x0000000000000000 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x000000c42000a020 x8: 0x00007ffdfffd4a00 x9: 0x00007ffdfffd4a08 x10: 0x0000000000000000 x11: 0x00000000ffffffff x12: 0x0000000000000000 x13: 0x00000000ffffffee x14: 0x0000000000000140 x15: 0x0000000000000100 x16: 0x000000000000016e x17: 0x0000000000000000 x18: 0x800000010000fb90 x19: 0x0000000100000000 x20: 0x00000000000007ff x21: 0x0000000100014fc0 x22: 0x00000002055eaac8 x23: 0x000000000150e224 x24: 0x00000000010243b0 x25: 0x00000000013022d0 x26: 0x00000000012f8cd8 x27: 0x0000000000000000 x28: 0x00000000010518fd fp: 0x00007ffdfff70b98 lr: 0x000000000150e254 sp: 0x000000010000fb90 pc: 0x00007ffdfff70bb0 cpsr: 0x80000000 far: 0x0000000000000018 esr: 0x92000006 Binary Images: 0x1000000 - 0x125efff + (???) 0x1014d3000 - 0x10156efff dyld (832.7.3) 0D4EA85F-7E30-338B-9215-314A5A5539B6 /usr/lib/dyld 0x7ffdfff5f000 - 0x7ffdfffd2fff +runtime (203.30) C98E75A6-BDC8-3D5C-B95B-6422005E96D8 /Library/Apple/*/runtime External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 4298 thread_create: 0 thread_set_state: 0 VM Region Summary: ReadOnly portion of Libraries: Total=3972K resident=0K(0%) swapped_out_or_unallocated=3972K(100%) Writable regions: Total=150.7M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=150.7M(100%) VIRTUAL REGION REGION TYPE SIZE COUNT (non-coalesced) =========== ======= ======= Rosetta Arena 2048K 1 Rosetta Generic 584K 143 Rosetta IndirectBranch 32K 1 Rosetta JIT 128.0M 1 Rosetta Return Stack 20K 2 Rosetta Thread Context 20K 2 VM_ALLOCATE 528.5G 9 VM_ALLOCATE (reserved) 8K 2 reserved VM address space (unallocated) __DATA 488K 6 __DATA_CONST 32K 1 __LINKEDIT 492K 5 __TEXT 3516K 3 mapped file 4.7G 12 =========== ======= ======= TOTAL 533.3G 188 TOTAL, minus reserved VM space 533.3G 188
Replies
2
Boosts
0
Views
4.9k
Activity
Nov ’21