Skip to content

Commit

Permalink
Fix: Use /dev/stdin only when available
Browse files Browse the repository at this point in the history
Commit e3c450a tried to fix the problem when sed does not accept '-'
as the identifier for reading from STDIN.

But not all Unix-like systems have /dev/stdin. So now we only use
it when available, otherwise the fallback is '-'.
  • Loading branch information
aureliojargas committed May 16, 2019
1 parent 302656b commit a49703d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sedsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
}

# The identifier recognized by sed as STDIN
if os.name == 'nt':
# Windows do not have /dev/stdin, maybe '-' is supported by sed
stdin_id = '-'
else:
# BSD sed fails for '-', use /dev/stdin as the default in Unix
# - BSD sed does not support '-'
# - Windows, Termux and others does not have /dev/stdin
if os.path.exists('/dev/stdin'):
stdin_id = '/dev/stdin'
else:
stdin_id = '-'


# -----------------------------------------------------------------------------
Expand Down

0 comments on commit a49703d

Please sign in to comment.