Fix from Tito to read from stdin only when it's not a tty.
authorRob Landley <rob@landley.net>
Wed, 7 Jun 2006 21:22:42 +0000 (21:22 -0000)
committerRob Landley <rob@landley.net>
Wed, 7 Jun 2006 21:22:42 +0000 (21:22 -0000)
include/usage.h
miscutils/hdparm.c

index 9bdfb3fe0f00c0a0a0cb7d461bb89bfebe1cdd94..0349f6916621e9782d6ba22df6070d6d56cc6fde 100644 (file)
@@ -994,7 +994,7 @@ USE_FEATURE_DATE_ISOFMT( \
 #define hdparm_trivial_usage \
        "[options] [device] .."
 #define hdparm_full_usage \
-       USE_FEATURE_HDPARM_GET_IDENTITY("\tIf no device name is specified read from stdin.\n") \
+       USE_FEATURE_HDPARM_GET_IDENTITY("\tIf no device name is specified try to read from stdin.\n") \
        "\nOptions:\n" \
        "\t-a   get/set fs readahead\n" \
        "\t-A   set drive read-lookahead flag (0/1)\n" \
index 5703eceb51effd5a158d78645b1b7ab9782c8d6c..512995a4be74b8f8d0bdcf1fe446fba1f2187b0f 100644 (file)
@@ -2185,11 +2185,11 @@ int hdparm_main(int argc, char **argv)
        argc -= optind;
        argv += optind;
 
-#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
        if (argc < 1) {
-               identify_from_stdin(); /* EXIT */
+               if (ENABLE_FEATURE_HDPARM_GET_IDENTITY && !isatty(STDIN_FILENO))
+                       identify_from_stdin(); /* EXIT */
+               else bb_show_usage();
        }
-#endif
 
        while (argc--) {
                process_dev(*argv);