expand.h revision 216778
120253Sjoerg/*- 220302Sjoerg * Copyright (c) 1991, 1993 320302Sjoerg * The Regents of the University of California. All rights reserved. 420253Sjoerg * 520253Sjoerg * This code is derived from software contributed to Berkeley by 620253Sjoerg * Kenneth Almquist. 720253Sjoerg * 820253Sjoerg * Redistribution and use in source and binary forms, with or without 920302Sjoerg * modification, are permitted provided that the following conditions 1020253Sjoerg * are met: 1120253Sjoerg * 1. Redistributions of source code must retain the above copyright 1220253Sjoerg * notice, this list of conditions and the following disclaimer. 1320253Sjoerg * 2. Redistributions in binary form must reproduce the above copyright 1420302Sjoerg * notice, this list of conditions and the following disclaimer in the 1520253Sjoerg * documentation and/or other materials provided with the distribution. 1620253Sjoerg * 4. Neither the name of the University nor the names of its contributors 1720302Sjoerg * may be used to endorse or promote products derived from this software 1820253Sjoerg * without specific prior written permission. 1920253Sjoerg * 2020253Sjoerg * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2120253Sjoerg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2220253Sjoerg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2320253Sjoerg * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2420253Sjoerg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2520253Sjoerg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2650479Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2720253Sjoerg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2820253Sjoerg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2920253Sjoerg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3020253Sjoerg * SUCH DAMAGE. 3120253Sjoerg * 3220253Sjoerg * @(#)expand.h 8.2 (Berkeley) 5/4/95 3320253Sjoerg * $FreeBSD: head/bin/sh/expand.h 216778 2010-12-28 21:27:08Z jilles $ 3420253Sjoerg */ 3520253Sjoerg 3620253Sjoergstruct strlist { 3744229Sdavidn struct strlist *next; 3820253Sjoerg char *text; 3920253Sjoerg}; 4020253Sjoerg 4120267Sjoerg 4220253Sjoergstruct arglist { 4320253Sjoerg struct strlist *list; 4444229Sdavidn struct strlist **lastp; 4520253Sjoerg}; 4620253Sjoerg 4720253Sjoerg/* 4820253Sjoerg * expandarg() flags 4920253Sjoerg */ 5020253Sjoerg#define EXP_FULL 0x1 /* perform word splitting & file globbing */ 5120253Sjoerg#define EXP_TILDE 0x2 /* do normal tilde expansion */ 5220267Sjoerg#define EXP_VARTILDE 0x4 /* expand tildes in an assignment */ 5352512Sdavidn#define EXP_REDIR 0x8 /* file glob for a redirection (1 match only) */ 5452512Sdavidn#define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */ 5520253Sjoerg#define EXP_SPLIT_LIT 0x20 /* IFS split literal text ${v+-a b c} */ 5620253Sjoerg#define EXP_LIT_QUOTED 0x40 /* for EXP_SPLIT_LIT, start off quoted */ 5720253Sjoerg 5820253Sjoerg 5920253Sjoergunion node; 6020253Sjoergvoid expandhere(union node *, int); 6120253Sjoergvoid expandarg(union node *, struct arglist *, int); 6220253Sjoergvoid expari(int); 6320253Sjoergint patmatch(const char *, const char *, int); 6420253Sjoergvoid rmescapes(char *); 6520253Sjoergint casematch(union node *, const char *); 6620253Sjoergint expandhassideeffects(const char *); 6720253Sjoergint wordexpcmd(int, char **); 6820253Sjoerg