var.c (169133) | var.c (169177) |
---|---|
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> | 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 169133 2007-04-30 15:01:33Z ache $"); | 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)) { | 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 (void) putenv(savestr(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)) { | 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 (void) putenv(savestr(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)) { | 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 (void) putenv(savestr(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{ | 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 char *eqp, *ss; | |
780 struct var **vpp; 781 struct var *vp; 782 783 vpp = hashvar(s); 784 for (vp = *vpp ; vp ; vpp = &vp->next, vp = *vpp) { 785 if (varequal(vp->text, s)) { 786 if (vp->flags & VREADONLY) 787 return (1); 788 INTOFF; 789 if (*(strchr(vp->text, '=') + 1) != '\0') 790 setvar(s, nullstr, 0); 791 if ((vp->flags & VEXPORT) && localevar(vp->text)) { | 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)) { |
792 ss = savestr(s); 793 if ((eqp = strchr(ss, '=')) != NULL) 794 *eqp = '\0'; 795 (void) unsetenv(ss); 796 ckfree(ss); | 791 unsetenv(s); |
797 setlocale(LC_ALL, ""); 798 } 799 vp->flags &= ~VEXPORT; 800 vp->flags |= VUNSET; 801 if ((vp->flags & VSTRFIXED) == 0) { 802 if ((vp->flags & VTEXTFIXED) == 0) 803 ckfree(vp->text); 804 *vpp = vp->next; --- 46 unchanged lines hidden --- | 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 --- |