Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
# /bin/true --version
true (GNU coreutils) 8.16
Упакован Gentoo (8.16 (p1))
Copyright (C) 2012 Free Software Foundation, Inc.
Лицензия GPLv3+: GNU GPL версии 3 или новее <http://gnu.org/licenses/gpl.html>
Это свободное ПО: вы можете продавать и распространять его.
Нет НИКАКИХ ГАРАНТИЙ до степени, разрешённой законом.
Автор программы -- Jim Meyering.
int i;" в прошлых топиках — просто лузеры в сравнении с AT&T.Report true bugs to bug-coreutils@gnu.org
@echo off
rem Copyright (c) 1984 AT&T
rem All Rights Reserved
rem THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
rem The copyright notice above does not evidence any
rem actual or intended publication of such source code.
rem ident "@(#)cmd/true.sh 50.1"
@echo off
rem Copyright (c) 1984 AT&T
rem All Rights Reserved
rem THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
rem The copyright notice above does not evidence any
rem actual or intended publication of such source code.
rem
rem Authors: DmZ@habrahabr.ru, amc@habrahabr.ru
rem Report bugs to: habrahabr.ru/post/144058/#comment_4832831
SET ERRORLEVEL=0
rem ident "@(#)cmd/true.sh 50.1"
make sandwich && false && rm -rf / # make научился делать сэндвичи, зачем удаляться?
#ident "@(#)clear.sh 1.8 96/10/14 SMI" /* SVr4.0 1.3 */
# Copyright (c) 1987, 1988 Microsoft Corporation
# All Rights Reserved
# This Module contains Proprietary Information of Microsoft
# Corporation and should be treated as Confidential.
# clear the screen with terminfo.
# if an argument is given, print the clear string for that tty type
/usr/bin/tput ${1:+-T$1} clear 2> /dev/null
exit
--- /dev/null
+++ b/src/true.c
@@ -0,0 +1,5 @@
+int
+main ()
+{
+ exit (0);
+}
+#include <config.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include "system.h"
+#include "version-etc.h"
+
+#define PROGRAM_NAME "true"
+#define AUTHORS "no one"
...
+Usage: %s\n\
+ or: %s OPTION\n\
+Exit with a status code indicating success.\n\
+These option names may not be abbreviated.
+\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+")
+ , program_name, program_name);
+ puts (_("\nReport bugs to <bug-sh-utils@gnu.org>."));
+ exit (status);
+}
...
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
...
-#define AUTHORS "no one"
+#define AUTHORS "Jim Meyering"
-#define PROGRAM_NAME "true"
+/* Act like "true" by default; false.c overrides this. */
+#ifndef EXIT_STATUS
+# define EXIT_STATUS EXIT_SUCCESS
+#endif
+
+#if EXIT_STATUS == EXIT_SUCCESS
+# define PROGRAM_NAME "true"
+#else
+# define PROGRAM_NAME "false"
+#endif
...
- exit (EXIT_SUCCESS);
+ exit (EXIT_STATUS);
- printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
+ emit_bug_reporting_address ();
- ? "Exit with a status code indicating success."
- : "Exit with a status code indicating failure."));
+ ? N_("Exit with a status code indicating success.")
+ : N_("Exit with a status code indicating failure.")));
* src/true.c (main): There is no reason to examine argv[0],
call atexit, etc., in the usual case in which we're about to exit.
This has the side effect of making it so that these programs
no longer segfault when subjected to execve abuse.
Before this change, these commands would make "true" segfault:
printf '%s\n' '#include <unistd.h>' 'int main(int c, char**v)' \
'{ execve (v[1], 0, 0); }' > k.c && gcc k.c && ./a.out $PWD/true
Now it succeeds. Reported by Tetsuo Handa and Bart Van Assche
via Ondřej Vašík in http://bugzilla.redhat.com/537684.
--- a/src/true.c
+++ b/src/true.c
@@ -54,18 +54,18 @@
int
main (int argc, char **argv)
{
- initialize_main (&argc, &argv);
- set_program_name (argv[0]);
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
-
- atexit (close_stdout);
-
/* Recognize --help or --version only if it's the only command-line
argument. */
if (argc == 2)
{
+ initialize_main (&argc, &argv);
+ set_program_name (argv[0]);
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
+ atexit (close_stdout);
+
mate /usr/bin/true
Apple Inc.
Apple Certification Authority
Apple Code Signing Certification Authority
Apple Root
TRUE(1) BSD General Commands Manual TRUE(1)
NAME
true -- Return true value.
SYNOPSIS
true
DESCRIPTION
The true utility always returns with exit code zero.
SEE ALSO
csh(1), sh(1), false(1)
STANDARDS
The true utility conforms to IEEE Std 1003.2-1992 (``POSIX.2'').
BSD June 27, 1991 BSD
(END)
Копирайт на команду /bin/true