-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically set up gcc and libstdc++ on macOS
- Loading branch information
Showing
4 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import glob | ||
|
||
|
||
def search_filesystem(pattern: str) -> None: | ||
""" | ||
Search the filesystem for files or directories that match the pattern | ||
:param pattern: The pattern to search for | ||
:return: None | ||
""" | ||
# Find files or directories that match the pattern | ||
matches = glob.glob(pattern, recursive=True) | ||
|
||
# Check if there are any matches | ||
if not matches: | ||
print(f"No matches found for pattern: {pattern}") | ||
else: | ||
# Sort matches in reverse order | ||
matches.sort(reverse=True) | ||
|
||
# Select the first match (after sorting in reverse order) | ||
print(matches[0]) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Check if exactly one argument is provided | ||
if len(sys.argv) != 2: | ||
print("Usage: python3 search.py <pattern>") | ||
sys.exit(1) | ||
|
||
search_filesystem(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is used to search for files or directories that match a pattern. | ||
# It searches recursively and returns the first match found. | ||
|
||
# Check if exactly one argument is provided | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <pattern>" | ||
exit 1 | ||
fi | ||
|
||
pattern=$1 | ||
|
||
# Find files or directories that match the pattern and store them in an array | ||
IFS=$'\n' read -d '' -r -a matches < <(find $(dirname "$pattern") -name "$(basename "$pattern")" | sort -r 2>/dev/null) | ||
|
||
# Check if any matches were found | ||
if [ ${#matches[@]} -eq 0 ]; then | ||
echo "No matches found." | ||
exit 1 | ||
else | ||
# Print the first match | ||
echo "${matches[0]}" | ||
fi |