1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/var.c 169177 2007-05-01 16:02:44Z ache $"); |
40 41#include <unistd.h> 42#include <stdlib.h> 43#include <paths.h> 44 45/* 46 * Shell variables. 47 */ --- 266 unchanged lines hidden (view full) --- 314 315 /* 316 * We could roll this to a function, to handle it as 317 * a regular variable function callback, but why bother? 318 */ 319 if (vp == &vmpath || (vp == &vmail && ! mpathset())) 320 chkmail(1); 321 if ((vp->flags & VEXPORT) && localevar(s)) { |
322 putenv(s); |
323 (void) setlocale(LC_ALL, ""); 324 } 325 INTON; 326 return; 327 } 328 } 329 /* not found */ 330 vp = ckmalloc(sizeof (*vp)); 331 vp->flags = flags; 332 vp->text = s; 333 vp->next = *vpp; 334 vp->func = NULL; 335 INTOFF; 336 *vpp = vp; 337 if ((vp->flags & VEXPORT) && localevar(s)) { |
338 putenv(s); |
339 (void) setlocale(LC_ALL, ""); 340 } 341 INTON; 342} 343 344 345 346/* --- 244 unchanged lines hidden (view full) --- 591 p++; 592 } else { 593 vpp = hashvar(name); 594 for (vp = *vpp ; vp ; vp = vp->next) { 595 if (varequal(vp->text, name)) { 596 597 vp->flags |= flag; 598 if ((vp->flags & VEXPORT) && localevar(vp->text)) { |
599 putenv(vp->text); |
600 (void) setlocale(LC_ALL, ""); 601 } 602 goto found; 603 } 604 } 605 } 606 setvar(name, p, flag); 607found:; --- 163 unchanged lines hidden (view full) --- 771 772/* 773 * Unset the specified variable. 774 */ 775 776int 777unsetvar(char *s) 778{ |
779 struct var **vpp; 780 struct var *vp; 781 782 vpp = hashvar(s); 783 for (vp = *vpp ; vp ; vpp = &vp->next, vp = *vpp) { 784 if (varequal(vp->text, s)) { 785 if (vp->flags & VREADONLY) 786 return (1); 787 INTOFF; 788 if (*(strchr(vp->text, '=') + 1) != '\0') 789 setvar(s, nullstr, 0); 790 if ((vp->flags & VEXPORT) && localevar(vp->text)) { |
791 unsetenv(s); |
792 setlocale(LC_ALL, ""); 793 } 794 vp->flags &= ~VEXPORT; 795 vp->flags |= VUNSET; 796 if ((vp->flags & VSTRFIXED) == 0) { 797 if ((vp->flags & VTEXTFIXED) == 0) 798 ckfree(vp->text); 799 *vpp = vp->next; --- 46 unchanged lines hidden --- |