4.1.3 Adding Anonymous Records

In a previous chapter we noted that recsel interprets the absence of a -t argument depending on the actual contents of the file. If the recfile contains records of just one type the command assumes that the user is referring to these records.

recins does not follow this convention, and the absence of an explicit type always means to insert (or replace) an anonymous record. Consider for example the following database:

%rec: Marks
%type: Class enum A B C

Name: Alfred
Class: A

Name: Bertram
Class: B

If we want to insert a new mark we have to specify the type explicitly using -t:

$ cat marks.rec | recins -t Marks -f Name -v Xavier -f Class -v C
%rec: Marks
%type: Class enum A B C

Name: Alfred
Class: A

Name: Bertram
Class: B

Name: Xavier
Class: C

If we forget to specify the type then an anonymous record is created instead:

$ cat marks.rec | recins -f Name -v Xavier -f Class -v C
Name: Xavier
Class: C

%rec: Marks
%type: Class enum A B C

Name: Alfred
Class: A

Name: Bertram
Class: B