From 623a982953080994b422982ca499fa28745d60f0 Mon Sep 17 00:00:00 2001 From: Gregory Chamberlain Date: Sat, 26 Sep 2020 04:26:53 +0100 Subject: [PATCH] Add section for testing file descriptor 0 --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index 2b2664c..4f200d8 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ See something incorrectly described, buggy or outright wrong? Open an issue or s * [Get the current working directory](#get-the-current-working-directory) * [Get the PID of the current shell](#get-the-pid-of-the-current-shell) * [Get the current shell options](#get-the-current-shell-options) + * [Check if input is from a terminal](#check-if-input-is-from-a-terminal) * [Check if output is to a terminal](#check-if-output-is-to-a-terminal) * [AFTERWORD](#afterword) @@ -1004,6 +1005,32 @@ This is an alternative to the `pwd` built-in. "$-" ``` +## Check if input is from a terminal + +You can test whether file descriptor 0 (i.e. standard input) is open +on a terminal using `[ -t 0 ]`. This test fails if input is +redirected from a file (`