Skip to content

Commit 5f5e76c

Browse files
committed
fix: Support only origin platforms without symlinks and aliases
Signed-off-by: Itamar Shalev <[email protected]>
1 parent fd8af2b commit 5f5e76c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ If it is not set, the client will try to determine the platform automatically ba
100100
The following values are supported:
101101
- `linux`
102102
- `windows`
103-
- `win32`
104103
- `android`
105-
- `darwin`
106104
- `freebsd`
107-
- `macos`
108105
- `netbsd`
109106
- `openbsd`
110107
- `osx`

tldr.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
"windows": "windows"
6060
}
6161

62+
SUPPORTED_PLATFORMS = sorted(set(OS_DIRECTORIES.values()))
63+
6264

6365
class CacheNotExist(Exception):
6466
pass
@@ -202,12 +204,15 @@ def update_page_for_platform(
202204

203205

204206
def get_platform() -> str:
205-
if platform := os.environ.get('TLDR_PLATFORM'):
206-
platform = platform.lower()
207-
if platform in OS_DIRECTORIES:
208-
return OS_DIRECTORIES[platform]
207+
platform_env = os.environ.get('TLDR_PLATFORM', '').strip().lower()
208+
if platform_env:
209+
if platform_env in SUPPORTED_PLATFORMS:
210+
return platform_env
209211
else:
210-
print("Warning: Invalid platform specified in environment variable TLDR_PLATFORM.")
212+
print(
213+
f"Warning: '{platform_env}' is not a supported platform specified in the "
214+
"TLDR_PLATFORM environment variable.\nFalling back to automatic detection."
215+
)
211216

212217
for key in OS_DIRECTORIES:
213218
if sys.platform.startswith(key):

0 commit comments

Comments
 (0)