; TeX output 1991.05.01:13553ڍ㍑{JNj cmbx12JGNUƧHistoryLibrary#$2K`y 3 cmr10BrianfFeo!xgFereefSoft!wareFeoundation^Veersionf1.1ĽAprilf1991*3ڍЍThisPdoMcumen!tdescribestheGNULHistorylibrarye,aprogrammingtoolthatpro!videsaconsistentuserfin!terfaceforrecallinglinesofpreviouslytypMedinput.!Publishedfb!ytheFereeSoftwareFeoundation675fMassac!husettsAvenue,Cam!bridge,fMA02139USAP!ermissionisgrantedtomakeanddistributeverbatimcopiesofthismanualprovidedthecopyrightnoticefandthispMermissionnoticearepreserv!edonallcopies.P!ermission\isgrantedtocopyanddistributemoMdi edversionsofthismanualundertheconditionsforv!erbatimcopying,!providedthattheentireresultingderivedworkisdistributedunderthetermsoffapMermissionnoticeiden!ticaltothisone.P!ermissionisgrantedtocopyanddistributetranslationsofthismanualintoanotherlanguage,under`ltheabMo!ve`lconditionsformodi edv!ersions,nkexceptthatthispermissionnoticema!ybestatedinfatranslationappro!vedfbytheFeoundation.7 Cop!yright7xcf !", cmsy10 L1989,f1991FereeSoft!warefFoundation,Inc.4Chapterf1:UsingHistoryIn!teractivelyt13ڍЍ;NG cmbx121 QUsingzHistoryInuteractively,Thisc!hapterdescribMeshowtousetheGNUѶHistoryLibraryinteractivelye,ܗfromauser'sstand-pMoin!t.h+ItԀshouldbeconsideredauser'sguide.h+FeorinformationonusingtheGNUtHistoryLibraryinfy!ourownprograms,seeChapter2[ProgrammingwithGNUHistory],page3.5@Nff cmbx12@1.1HistoryffInteraction!The/Historylibrarypro!videsahistoryexpansionfeaturethatissimilartothehistoryexpansionin_9Csh.#Thefollo!wingtextdescribMesthesytaxthatyouusetomanipulatethehistoryinformation.History_expansiontak!esplaceintwoparts. JThe rstistodeterminewhichlinefromtheprevioushistoryshouldbMeusedduringsubstitution.hThesecondistoselectportionsofthatlineforeinclusionin!tothecurrentone.Thelineselectedfromtheprevioushistoryiscalledthe6p0J 3 cmsl10event,and^thepMortionsofthatlinethatareacteduponarecalledw!ords.ThelineisbrokenintowordsinthesamefashionthattheBashshelldoMes,sothatsev!eralEnglish(orUnix)wordssurroundedb!yfquotesareconsideredasoneword.1EN # cmbx12E1.1.1d(EventpDesignatorsAnfev!entdesignatorisareferencetoacommandlineentryinthehistorylist.3lines.I@2.4HistoryffVfariables#0ThisfsectiondescribMesthevdDariablesinGNUHistorythatareexternallyvisible.%VeariableUintyhistory/xH'baseUFeorcon!venienceonlye.9Yousetthiswhenin!terpretinghistorycommands.9ItistheUlogicalfo setofthe rsthistoryelemen!t.3Chapterf2:ProgrammingwithGNUHistoryX73ڍЍ@2.5HistoryffProgrammingExample#Theffollo!wingsnippMetofcodedemonstratessimpleuseoftheGNUHistoryLibrarye.Umain() U{(gcharline[1024],*t;(gintdone=0;(gline[0]=0;(gwhile(!done) 3{?fQfprintf(stdout,"history%%");?fQt=gets(line);?fQif(!t)Jstrcpy(line,"quit");?fQif(line[0])J{Vdchar*expansion;Vdintresult;Vdusing_history();Vdresult=history_expand(line,&expansion);Vdstrcpy(line,expansion);Vdfree(expansion);Vdif(result)aMfprintf(stderr,"%s\n",line);Vdif(result<0)aMcontinue;Vdadd_history(line);J}?fQif(strcmp(line,"quit")==0)done=1;?fQif(strcmp(line,"save")==0)write_history(0);?fQif(strcmp(line,"read")==0)read_history(0);?fQif(strcmp(line,"list")==0)J{VdregisterHIST_ENTRY**the_list=history_list();Vdregisterinti;Vdif(the_list)aMfor(i=0;the_list[i];i++)mcfprintf(stdout,"%d:%s\n",<8bGNUfReadlineLibrary3ڍЍ~i+history_base,the_list[i]->line); J}?fQif(strncmp(line,"delete",strlen("delete"))==0)J{Vdintwhich;Vdif((sscanf(line+strlen("delete"),"%d",&which))==1)aM{mcHIST_ENTRY*entry=remove_history(which);mcif(!entry)xfprintf(stderr,"Nosuchentry%d\n",which);mcelsex{bIfree(entry->line);bIfree(entry);x}aM}VdelseaM{mcfprintf(stderr,"non-numericarggivento`delete'\n");aM}J}3}U} AAppMendixfA:ConceptIndexI:93ڍЍApp=endixzA QConceptIndex4\(o cmr9(IndexTisempt9y) DH10]+GNUfReadlineLibrary3ڟ EAppMendixfB:FeunctionandVariableIndex113ڍЍApp=endixzB QFaGunctionandVariableIndex4\((IndexTisempt9y) Ex12]+GNUfReadlineLibrary3ڟF[Ҷi3ڍЍTaGablezofConutents*@132UsingffHistoryInteractivelyCUT b> cmmi10:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:@1$1.1 5HistoryfIn!teractionGT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:1H1.1.1 5Ev!entfDesignatorsZT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:81H1.1.2 5WeordfDesignators_T:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:p1H1.1.3 5MoMdi ers䍑T:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:x2@232ProgrammingffwithGNUHistoryFIT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:@3$2.1 5In!troMductionftoHistorywjT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:%3$2.2 5HistoryfStoragee$T:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:3$2.3 5HistoryfFeunctionsэT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:4$2.4 5HistoryfVeariables܍T:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:L6$2.5 5HistoryfProgrammingExampleT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:0h7@Apps3endixffA32ConceptIndexۍT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:@9!Apps3endixffB32FfunctionandVariableIndexnT:qōT:T:T:T:T:T:T:T:T:T:T:T:T:T:T:T:P@11FiibGNUfReadlineLibrary3ڟ\;3GJNj cmbx12EN # cmbx12@Nff cmbx12;NG cmbx129"V cmbx107m#R 3 cmss106p0J 3 cmsl103 cmmi10o cmr9\n