/* Copyright (c) 1979 Regents of the University of California */
* Still more user commands.
* Process a shell escape by saving signals, ignoring signals,
int (*sig
[2])(), stat
[1];
if ((Shell
= value("SHELL")) == NOSTR
)
sig
[t
-2] = signal(t
, SIG_IGN
);
execl(Shell
, Shell
, "-c", str
, 0);
* Print out a nice help message from some file or another.
if ((f
= fopen(HELPFILE
, "r")) == NULL
) {
printf("No help just now.\n");
while ((c
= getc(f
)) != EOF
)
* Change user's working directory.
for (cp
= str
; *cp
== ' '; cp
++)
* Reply to a list of messages. Extract each name from the
* message header and send them off to mail()
register struct message
*mp
;
for (ip
= msgvec
, s
= 0; *ip
; ip
++) {
s
+= strlen(nameof(mp
))+1;
for (ip
= msgvec
; *ip
; ip
++) {
cp2
= copy(nameof(mp
), cp2
);
mp
= &message
[msgvec
[0]-1];
head
.h_subj
= hfield("subj", mp
);
head
.h_cc
= hfield("cc", mp
);
* Preserve the named messages, so that they will be sent
* back to the system mailbox.
register struct message
*mp
;
printf("Cannot \"preserve\" in edit mode\n");
for (ip
= msgvec
; *ip
!= NULL
; ip
++) {
* Print the size of each message.
register struct message
*mp
;
for (ip
= msgvec
; *ip
!= NULL
; ip
++) {
printf("%d: %d\n", mesg
, msize(mp
));
* Quit quickly. If we are sourcing, just pop the input level
* Set or display a variable value. Syntax is similar to that
char varbuf
[BUFSIZ
], **ap
, **p
;
if (argcount(arglist
) == 0) {
for (h
= 0, s
= 1; h
< HSHSIZE
; h
++)
for (vp
= variables
[h
]; vp
!= NOVAR
; vp
= vp
->v_link
)
ap
= (char **) salloc(s
* sizeof *ap
);
for (h
= 0, p
= ap
; h
< HSHSIZE
; h
++)
for (vp
= variables
[h
]; vp
!= NOVAR
; vp
= vp
->v_link
)
for (p
= ap
; *p
!= NOSTR
; p
++)
printf("%s\t%s\n", *p
, value(*p
));
for (ap
= arglist
; *ap
!= NOSTR
; ap
++) {
while (*cp
!= '=' && *cp
!= '\0')
printf("Non-null variable name required\n");
* Unset a bunch of variable values.
register struct var
*vp
, *vp2
;
for (ap
= arglist
; *ap
!= NOSTR
; ap
++) {
if ((vp2
= lookup(*ap
)) == NOVAR
) {
printf("\"%s\": undefined variable\n", *ap
);
if (vp2
== variables
[h
]) {
variables
[h
] = variables
[h
]->v_link
;
for (vp
= variables
[h
]; vp
->v_link
!= vp2
; vp
= vp
->v_link
)
vp
->v_link
= vp2
->v_link
;
* Put add users to a group.
register struct grouphead
*gh
;
register struct group
*gp
;
if (argcount(argv
) == 0) {
for (h
= 0, s
= 1; h
< HSHSIZE
; h
++)
for (gh
= groups
[h
]; gh
!= NOGRP
; gh
= gh
->g_link
)
ap
= (char **) salloc(s
* sizeof *ap
);
for (h
= 0, p
= ap
; h
< HSHSIZE
; h
++)
for (gh
= groups
[h
]; gh
!= NOGRP
; gh
= gh
->g_link
)
for (p
= ap
; *p
!= NOSTR
; p
++)
if (argcount(argv
) == 1) {
if ((gh
= findgroup(gname
)) == NOGRP
) {
gh
= (struct grouphead
*) calloc(sizeof *gh
, 1);
gh
->g_name
= vcopy(gname
);
* Insert names from the command list into the group.
* Who cares if there are duplicates? They got tossed
for (ap
= argv
+1; *ap
!= NOSTR
; ap
++) {
gp
= (struct group
*) calloc(sizeof *gp
, 1);
gp
->ge_name
= vcopy(*ap
);
gp
->ge_link
= gh
->g_list
;
* Sort the passed string vecotor into ascending dictionary
for (ap
= list
; *ap
!= NOSTR
; ap
++)
qsort(list
, ap
-list
, sizeof *list
, diction
);
* Do a dictionary order comparison of the arguments from
* The do nothing command for comments.