* DISPLAY DOCUMENTS:: Display active file documents.
* DISPLAY FILE LABEL:: Display the active file label.
* DROP DOCUMENTS:: Remove documents from the active file.
+* ERASE:: Erase a file.
* EXECUTE:: Execute pending transformations.
* FILE LABEL:: Set the active file's label.
* FINISH:: Terminate the PSPP session.
active file,
if any. @xref{FILE LABEL}.
-@node DROP DOCUMENTS, EXECUTE, DISPLAY FILE LABEL, Utilities
+@node DROP DOCUMENTS, ERASE, DISPLAY FILE LABEL, Utilities
@section DROP DOCUMENTS
@vindex DROP DOCUMENTS
@cmd{DROP DOCUMENTS} changes only the active file. It does not modify any
system files stored on disk.
-@node EXECUTE, FILE LABEL, DROP DOCUMENTS, Utilities
+
+@node ERASE, EXECUTE, DROP DOCUMENTS, Utilities
+@comment node-name, next, previous, up
+@section ERASE
+@vindex ERASE
+
+@display
+ERASE FILE file_name.
+@end display
+
+@cmd{ERASE FILE} deletes a file from the local filesystem.
+file_name must be quoted.
+This command cannot be used if the SAFER setting is active.
+
+
+@node EXECUTE, FILE LABEL, ERASE, Utilities
@section EXECUTE
@vindex EXECUTE
@cmd{HOST} suspends the current PSPP session and temporarily returns control
to the operating system.
+This command cannot be used if the SAFER setting is active.
@node INCLUDE, QUIT, HOST, Utilities
return lex_end_of_command ();
}
+
+#define assert_not_safer() \
+ do { \
+ if (set_safer) \
+ { \
+ msg (SE, _("This command not allowed when the SAFER option is set.")); \
+ return CMD_FAILURE; \
+ } \
+} while(0)
+
+
+
/* Parses, performs the ERASE command. */
int
cmd_erase (void)
{
- if (set_safer)
- {
- msg (SE, _("This command not allowed when the SAFER option is set."));
- return CMD_FAILURE;
- }
+
+ assert_not_safer();
lex_match_id ("ERASE");
if (!lex_force_match_id ("FILE"))
return CMD_FAILURE;
}
- return lex_end_of_command ();
+ return CMD_SUCCESS;
}
#if unix
{
int code;
- if (set_safer)
- {
- msg (SE, _("This command not allowed when the SAFER option is set."));
- return CMD_FAILURE;
- }
+ assert_not_safer();
lex_match_id ("HOST");
command/count.sh \
command/compute.sh \
command/descriptives.sh \
+ command/erase.sh \
command/file-label.sh \
command/filter.sh \
command/flip.sh \
--- /dev/null
+#!/bin/sh
+
+# This program tests the ERASE command.
+
+TEMPDIR=/tmp/pspp-tst-$$
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+ rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+ echo $activity
+ echo FAILED
+ cleanup;
+ exit 1;
+}
+
+
+no_result()
+{
+ echo $activity
+ echo NO RESULT;
+ cleanup;
+ exit 2;
+}
+
+pass()
+{
+ cleanup;
+ exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create file"
+cat > $TEMPDIR/foobar <<EOF
+xyzzy
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="check for file 1"
+if [ ! -f $TEMPDIR/foobar ] ; then no_result ; fi
+
+
+activity="create program 1"
+cat > $TEMPDIR/foo.sps <<EOF
+set safer on
+
+erase FILE='foobar'.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+# foobar must still exist
+activity="check for file 2"
+if [ ! -f $TEMPDIR/foobar ] ; then fail ; fi
+
+# This command must fail
+activity="run prog 1"
+$here/../src/pspp $TEMPDIR/foo.sps > /dev/null
+if [ $? -eq 0 ] ; then fail ; fi
+
+
+activity="create program 2"
+cat > $TEMPDIR/foo.sps <<EOF
+
+erase FILE='foobar'.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run prog 1"
+$here/../src/pspp $TEMPDIR/foo.sps
+if [ $? -ne 0 ] ; then fail ; fi
+
+# foobar should now be gone
+if [ -f $TEMPDIR/foobar ] ; then fail ; fi
+
+
+
+
+
+
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+
+pass;