/* $NetBSD: env.c,v 1.23 2020/02/08 11:02:07 kamil Exp $ */ /* * Copyright (c) 1988, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\ The Regents of the University of California. All rights reserved."); #endif /* not lint */ #ifndef lint /*static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";*/ __RCSID("$NetBSD: env.c,v 1.23 2020/02/08 11:02:07 kamil Exp $"); #endif /* not lint */ #include #include #include #include #include #include #include static void usage(void) __dead; extern char **environ; int main(int argc, char **argv) { char **ep, term; char *cleanenv[1]; int ch; setprogname(*argv); (void)setlocale(LC_ALL, ""); term = '\n'; while ((ch = getopt(argc, argv, "-0iu:")) != -1) switch((char)ch) { case '0': term = '\0'; break; case '-': /* obsolete */ case 'i': environ = cleanenv; cleanenv[0] = NULL; break; case 'u': if (unsetenv(optarg) == -1) errx(EXIT_FAILURE, "unsetenv %s", optarg); break; case '?': default: usage(); } for (argv += optind; *argv && strchr(*argv, '=') != NULL; ++argv) (void)putenv(*argv); if (*argv) { /* return 127 if the command to be run could not be found; 126 if the command was found but could not be invoked; 125 if -0 was specified with utility.*/ if (term == '\0') errx(125, "cannot specify command with -0"); (void)execvp(*argv, argv); err((errno == ENOENT) ? 127 : 126, "%s", *argv); /* NOTREACHED */ } for (ep = environ; *ep; ep++) (void)printf("%s%c", *ep, term); exit(0); } static void usage(void) { (void)fprintf(stderr, "Usage: %s [-0i] [-u name] [name=value ...] [command]\n", getprogname()); exit(1); } stringjoerg 2019-06-20Re-add msg_clear() accidently dropped in previous.martin 2019-06-20Introduce _fmt_ flavors of the menu functions that take a formatting stringchristos 2019-03-01msg_prompt_win: allow automatic window height calculation (by passingmartin 2019-01-22Support redrawing all windows when in a msg prompt via Ctrl-l.martin 2019-01-21msg_prompt_win: if the default string fits, show it separately evenmartin 2012-03-06Remove the advertising clause with the explicit ok from Perry E. Metzger.mbalmer 2012-03-02Add msg_printf(fmt, ...), a function to display raw messages withoutmbalmer 2012-03-02Removing trailing whitespace.mbalmer 2010-01-02Remove some sign compare warnings.dsl 2006-12-03eliminate an alloca use.christos 2006-09-06Fix requests for msg input with a NULL target buffer (or zero length one)dsl 2006-09-06Rename 'max_chars' to 'val_buf_len' to make it clearer that it has to includedsl 2006-05-12Sorry, fix syntax error in previous.he 2006-05-12Appease gcc 3.3.3 -Wuninitialized warning; fixes build problem forhe 2005-04-09If the user removed the default string (after we had put it into the bufferdsl 2004-11-05Add (unsigned char) cast to ctype functionsdsl 2004-10-16Remove _erase_ch() it isn't used any moredsl 2004-08-14NetBSD curses gives the wrong data when you read curscr, need todsl 2004-08-13Save and restore screen underneath prompt boxesdsl 2004-06-05Improve editing of input fields:dsl 2003-09-25Add a msg_row() function that returns the current screen row.dsl 2003-07-28No need for wrefresh() in msg_clear(), screen will be updated later.dsl 2003-07-25Change variable name to compiles with WARNS=3dsl 2003-07-14use bounded string opitojun 2003-07-07Change 'Magic number' of menu text files.dsl 2003-06-27Add support for reading messages from a text file - msg_file() and msg_string().dsl 2003-06-10Change msg_window() to return old window (temp buffer size isn't too important)dsl 2003-06-04Add msg_prompt_win() that will prompt in the specified window (instead ofdsl 2003-01-10produce lint free code.christos 1999-07-04nuke msg_printf() and msg_printf_add().cgd 1999-07-04const-ify strings as appropriate, and convert message 'numbers' fromcgd 1999-07-04oops, forgot an _cgd 1999-07-04privatize msg_beepcgd 1999-07-04nuke msg_{,no}echo, add msg_prompt_noechocgd 1999-07-04nuke msg_prompt_str, msg_prompt_addstr, and msg_table (unused), and makecgd 1999-07-04turn on automatic text layout for the printf and display fnscgd 1999-07-04provide APIs (currently mostly undocumented) to print pre-formattedcgd 1999-06-23implement word kill with control-Wcgd 1999-06-23add code to do dynamic message text layout, currently completely disabled.cgd 1999-06-23replace lots of wclear()/wmove() calls with calls to msg_clear(). wmove()cgd 1999-06-22don't bother calculated up MAXSTR, especially since the value calculatedcgd 1999-06-19don't dereference NULL when thinking about copying the defaultcgd 1999-06-19teach the message prompting code to use control-U as line kill character.cgd 1999-06-19fix an off-by-one error (it would put up to max_chars plus NUL into the string,cgd 1999-04-25It was a bad idea to call a function 'beep'.veego