Reputation: 1
Sorry for what might be a stupid question, but this is really bugging me and google has not turned up any good/relevant answers...
!w now prefixes my PATH and a new Shared folder has been created in /Users.
I was writing two programs, one in C++ and the other in Python. I wanted to compare compilation time between the two.
Python program:
import sys
line_count = 0
input_line = ''
for line in sys.stdin:
input_line = line
line_count += 1
print("Total lines read:", line_count)
C++ program:
#include <iostream>
#include <string>
using namespace std;
int main() {
string input_line;
int line_count = 0;
while (getline(cin, input_line)) {
line_count++;
}
cout << "Total lines read: " << line_count << endl;
return 0;
}
First I wrote a python script to generate a .txt file containing 1,000,000 lines of "Hello, world!" to use as test data for the aforementioned programs. This was the script:
import sys
output_file = "helloWorld_1mil.txt"
with open(output_file, "w") as f:
sys.stdout = f # Redirect print output to the file
# Print 1000000 lines of "Hello, world!"
for i in range(1, 1000001):
print(f"{i}: Hello, world!")
sys.stdout = sys.__stdout__
print(f"Output saved to {output_file}")
I saved this .txt file in my user profile and then moved it into /tmp with mv filename.py /tmp
I then cd /tmp from my user to see if the file had been moved there. Upon cd .. I noticed that the !w now prefixed my path all the way to my root directory. A Shared folder was also created in /Users. I am unable to read any of the contents of this folder.
From my root directory ECHO $PATH now reads:
!w / ................................................................ 04:28:43
ECHO $PATH /Library/Frameworks/Python.framework/Versions/3.13/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/mysql-9.2.0-macos15-arm64/bin
ls -l /Users/Shared !w / ................................................................ 04:28:52
ls -l /Users/Shared total 0 drwxr-xr-x@ 3 [myusername] wheel 96 Apr 15 2024 Library drwxr-xr-x@ 4 [myusername] wheel 128 Oct 29 19:28 Max 8 drwxr-xr-x 4 root wheel 128 Nov 11 10:15 Previously Relocated Items drwxr-xr-x 4 root wheel 128 Feb 25 21:07 Relocated Items drwxrwxrwx@ 2 [myusername] wheel 64 Apr 4 2024 SC Info
Zsh History Expansion: I know that "!" in zsh is the history character, and "w" Expands to owner-writeable files.
My question(s) are:
Why is !w in my path? Can I remove it along with the Shared folder in /Users? If so, how?
What does !w really mean in my path? The documentation hasn't been particularly helpful in explaining what !w means in relation to my path.
What would removing the Shared folder in /Users do?
I copied the original programs and additional python script and removed them from their respective directories. I then hard reset my terminal hoping it would make !w go away (it did not). I tried Google, Reddit, and even GPT to see what !w really means and how to remove it. I could not find anyone who had asked a similar question on here or on Reddit.
Upvotes: -1
Views: 21