ksh93.man 120 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986
  1. .\" $XConsortium: ksh93.man /main/2 1995/07/17 10:51:12 drk $
  2. .\"
  3. .\" David Korn
  4. .\" AT&T Bell Laboratories
  5. .\"
  6. .\" @(#)sh.1 (ulysses!dgk) 01/14/93-beta15
  7. .\"
  8. .nr Z 1 \" set to 1 when command name is ksh rather than sh
  9. .nr Y 0 \" set to 1 for R&D UNIX
  10. .if \nY=1 .nr Z 1
  11. .ds OK [\|
  12. .ds CK \|]
  13. .ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
  14. .ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
  15. .de P
  16. .br
  17. ..
  18. .if \nZ=0 .TH SH 1
  19. .if \nZ=1 .TH KSH 1 "User Environment Utilities" "RDS Standard"
  20. .SH NAME
  21. .if \nZ=0 sh, rsh \- shell, the
  22. .if \nZ=1 ksh, rksh \- KornShell, a
  23. standard/restricted command and programming language
  24. .SH SYNOPSIS
  25. .if \nZ=0 .B sh
  26. .if \nZ=1 .B ksh
  27. [
  28. .B \(+-abcefhikmnoprstuvxCP
  29. ] [
  30. .B \-I
  31. file ] [
  32. .B \(+-o
  33. option ] .\|.\|. [
  34. .B \-
  35. ] [ arg .\|.\|. ]
  36. .br
  37. .if \nZ=0 .B rsh
  38. .if \nZ=1 .B rksh
  39. [
  40. .B \(+-abcefhikmnoprstuvxCP
  41. ] [
  42. .B \-I
  43. file ] [
  44. .B \(+-o
  45. option ] .\|.\|. [
  46. .B \-
  47. ] [ arg .\|.\|. ]
  48. .SH DESCRIPTION
  49. .if \nZ=0 .I Sh\^
  50. .if \nZ=1 .I Ksh\^
  51. is a command and programming language
  52. that executes commands read from a terminal
  53. or a file.
  54. .if \nZ=0 .I Rsh\^
  55. .if \nZ=1 .I Rksh\^
  56. is a restricted version of the
  57. .if \nZ=0 standard
  58. command interpreter
  59. .if \nZ=0 .IR sh ;
  60. .if \nZ=1 .IR ksh ;
  61. it is used to set up login names and execution environments whose
  62. capabilities are more controlled than those of the standard shell.
  63. See
  64. .I Invocation\^
  65. below
  66. for the meaning of arguments to the shell.
  67. .SS Definitions.
  68. A
  69. .I metacharacter\^
  70. is one of the following characters:
  71. .RS
  72. .PP
  73. \f3; & ( ) \(bv < > new-line space tab\fP
  74. .RE
  75. .PP
  76. A
  77. .I blank\^
  78. is a
  79. .B tab
  80. or a
  81. .BR space .
  82. An
  83. .I identifier\^
  84. is a sequence of letters, digits, or underscores
  85. starting with a letter or underscore.
  86. Identifiers are used as components of
  87. .I variable\^
  88. names.
  89. A
  90. .I vname\^
  91. is a sequence of one or more identifiers
  92. separated by a \fB\s+2.\s-2\fP and optionally preceded
  93. by a \fB\s+2.\s-2\fP.
  94. Vnames are used as function and variable names.
  95. A
  96. .I word\^
  97. is a sequence of
  98. .I characters\^
  99. excluding non-quoted
  100. .IR metacharacters .
  101. .P
  102. A
  103. .I command\^
  104. is a sequence of characters in the syntax
  105. of the shell language.
  106. The shell reads each command and
  107. carries out the desired action either directly or by invoking
  108. separate utilities.
  109. A built-in command is a command that is carried out by the
  110. shell itself without creating a separate process.
  111. Some commands are built-in purely for convenience
  112. and are not documented here.
  113. Built-ins that cause
  114. side effects in the shell environment and
  115. built-ins that are found before performing a
  116. path search (see
  117. .I Execution\^
  118. below)
  119. are documented here.
  120. For historical reasons, some of
  121. these built-ins behave differently than
  122. other built-ins and are called
  123. .IR "special built-ins" .
  124. .SS Commands.
  125. A
  126. .I simple-command\^
  127. is a list of variable assignments
  128. (see
  129. .I Variable Assignments\^
  130. below)
  131. or a sequence of
  132. .I blank\^
  133. separated words
  134. which may be preceded by a list of variable assignments
  135. (see
  136. .I Environment\^
  137. below).
  138. The first word specifies the name of the command to
  139. be executed.
  140. Except as specified below,
  141. the remaining words are passed as arguments
  142. to the invoked command.
  143. The command name is passed as argument 0
  144. (see
  145. .IR exec (2)).
  146. The
  147. .I value\^
  148. of a simple-command is its exit status; 0-255
  149. if it terminates normally; 256+\f2signum\^\fP if
  150. it terminates abnormally (the name of the signal corresponding
  151. to the exit status can be
  152. obtained via the
  153. .B "\-l $?"
  154. option of the
  155. .B kill\^
  156. built-in utility).
  157. .PP
  158. An
  159. .I "arithmetic command"
  160. begins with a
  161. .BR (( ,
  162. and consists of an arithmetic expression formed by
  163. all the characters until a matching
  164. .BR )) .
  165. (See
  166. .I "Arithmetic evaluation"
  167. below.)
  168. The exit status of an arithmetic command is 0 when the
  169. arithmetic expression evaluates to a non-zero value and
  170. is 1 when the arithmetic expression evaluates to 0.
  171. .PP
  172. A
  173. .I pipeline\^
  174. is a sequence of one or more
  175. .I commands\^
  176. separated by
  177. .BR \(bv .
  178. The standard output of each command but the last
  179. is connected by a
  180. .IR pipe (2)
  181. to the standard input of the next command.
  182. Each command,
  183. except possibly the last,
  184. is run as a separate process;
  185. the shell waits for the last command to terminate.
  186. The exit status of a pipeline is the exit
  187. status of the last command.
  188. Each pipeline can be preceded by the
  189. .I "reserved word"
  190. .B !
  191. which negates the exit status of the pipeline.
  192. .PP
  193. A
  194. .I list\^
  195. is a sequence of one or more
  196. pipelines
  197. separated by
  198. .BR ; ,
  199. .BR & ,
  200. .BR \(bv& ,
  201. .BR && ,
  202. or
  203. .BR \(bv\|\(bv ,
  204. and optionally terminated by
  205. .BR ; ,
  206. .BR & ,
  207. or
  208. .BR \(bv& .
  209. Of these five symbols,
  210. .BR ; ,
  211. .BR & ,
  212. and
  213. .B \(bv&
  214. have equal precedence,
  215. which is lower than that of
  216. .B &&
  217. and
  218. .BR \(bv\|\(bv .
  219. The symbols
  220. .B &&
  221. and
  222. .B \(bv\|\(bv
  223. also have equal precedence.
  224. A semicolon
  225. .RB ( ; )
  226. causes sequential execution of the preceding pipeline; an ampersand
  227. .RB ( & )
  228. causes asynchronous execution of the preceding pipeline (i.e., the shell does
  229. .I not\^
  230. wait for that pipeline to finish).
  231. The symbol
  232. .B \(bv&
  233. causes asynchronous execution of the preceding pipeline
  234. with a two-way pipe established to the parent shell;
  235. the standard input and output of the spawned pipeline
  236. can be written to and read from by the parent shell
  237. by applying
  238. the redirection operators
  239. .B <&
  240. and
  241. .B >&
  242. with arg
  243. .B p
  244. to commands and by using
  245. .B \-p
  246. option of
  247. the built-in commands
  248. .B read
  249. and
  250. .B print
  251. described later.
  252. The symbol
  253. .B &&
  254. .RB (\| \(bv\|\(bv \^)
  255. causes the
  256. .I list\^
  257. following it to be executed only if the preceding
  258. pipeline
  259. returns a zero (non-zero) value.
  260. An arbitrary number of new-lines may appear in a
  261. .I list\^
  262. instead of a semicolon,
  263. to delimit a command.
  264. .PP
  265. A
  266. .I command\^
  267. is either a simple-command
  268. or one of the following.
  269. Unless otherwise stated,
  270. the value returned by a command is that of the
  271. last simple-command executed in the command.
  272. .TP
  273. \f3for\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
  274. Each time a
  275. .B for
  276. command is executed,
  277. .I name\^
  278. is set to the next
  279. .I word\^
  280. taken from the
  281. .B in
  282. .I word\^
  283. list.
  284. If
  285. .BI in " word\^"
  286. \&.\|.\|.
  287. is omitted, then
  288. the
  289. .B for
  290. command executes the \f3do\fP \f2list\^\fP once for each positional parameter
  291. that is set
  292. (see
  293. .I "Parameter Expansion\^"
  294. below).
  295. Execution ends when there are no more words in the list.
  296. .TP
  297. \f3for ((\fP \*(OK\f2expr1\^\fP\*(CK \f3;\fP \*(OK\f2expr2\^\fP\*(CK \f3;\fP \*(OK\f2expr3\^\fP\*(CK \f3))\fP \f3;do\fP \f2list\^\fP \f3;done\fP
  298. The arithmetic expression
  299. .I expr1
  300. is evaluated first.
  301. (See
  302. .I "Arithmetic evaluation"
  303. below.)
  304. The arithmetic expression
  305. .I expr2
  306. is repeatedly evaluated until it evalues to zero and when non-zero,
  307. .I list
  308. is executed and the arithmetic expression
  309. .I expr3
  310. evaluated.
  311. If any expression
  312. is omitted, then it behaves as if it evaluated to 1.
  313. .TP
  314. \f3select\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
  315. A
  316. .B select
  317. command prints on standard error (file descriptor 2) the set of
  318. .IR word s,
  319. each preceded by a number.
  320. If
  321. .BI in " word\^"
  322. \&.\|.\|.
  323. is omitted, then
  324. the
  325. positional parameters
  326. are used instead
  327. (see
  328. .I "Parameter Expansion\^"
  329. below).
  330. The
  331. .SM
  332. .B PS3
  333. prompt is printed
  334. and a line is read from the standard input.
  335. If this line consists of the number
  336. of one of the listed
  337. .IR word s,
  338. then the value of the variable
  339. .I vname\^
  340. is set to the
  341. .I word\^
  342. corresponding to this number.
  343. If this line is empty the selection list is
  344. printed again.
  345. Otherwise the value of the variable
  346. .I vname\^
  347. is set to
  348. .IR null .
  349. The contents of the line read from standard input is
  350. saved in
  351. the variable
  352. .SM
  353. .BR REPLY .
  354. The
  355. .I list\^
  356. is executed for each selection until a
  357. .B break\^
  358. or
  359. .I end-of-file\^
  360. is encountered.
  361. If the
  362. .SM
  363. .B REPLY
  364. variable is set to
  365. .I null\^
  366. by the execution of
  367. .IR list ,
  368. then the selection list is printed before
  369. displaying the
  370. .SM
  371. .B PS3
  372. prompt for the next selection.
  373. .TP
  374. \f3case\fP \f2word\^\fP \f3in\fP \*(OK \*(OK\f3(\fP\*(CK\f2pattern\^\fP \*(OK \(bv \f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
  375. A
  376. .B case
  377. command executes the
  378. .I list\^
  379. associated with the first
  380. .I pattern\^
  381. that matches
  382. .IR word .
  383. The form of the patterns is
  384. the same as that used for
  385. file-name generation (see
  386. .I "File Name Generation\^"
  387. below).
  388. The
  389. .B ;;
  390. operator causes execution of
  391. .B case
  392. to terminate.
  393. If
  394. .B ;&
  395. is used in place of
  396. .B ;;
  397. the next subsequent list, if any, is executed.
  398. .ll +3
  399. .TP
  400. \f3if\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(OK \
  401. \f3elif\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(CK .\|.\|. \
  402. \*(OK \f3;else\fP \f2list\^\fP \*(CK \f3;f\&i\fP
  403. .ll -3
  404. The
  405. .I list\^
  406. following \f3if\fP is executed and,
  407. if it
  408. returns a zero exit status, the
  409. .I list\^
  410. following
  411. the first
  412. .B then
  413. is executed.
  414. Otherwise, the
  415. .I list\^
  416. following \f3elif\fP
  417. is executed and, if its value is zero,
  418. the
  419. .I list\^
  420. following
  421. the next
  422. .B then
  423. is executed.
  424. Failing that, the
  425. .B else
  426. .I list\^
  427. is executed.
  428. If the
  429. .B if
  430. .I list\^
  431. has non-zero exit status
  432. and there is no
  433. .B else
  434. .IR list ,
  435. then the
  436. .B if
  437. command returns a zero exit status.
  438. .TP
  439. .PD 0
  440. \f3while\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
  441. .TP
  442. \f3until\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
  443. .PD
  444. A
  445. .B while
  446. command repeatedly executes the
  447. .B while
  448. .I list\^
  449. and, if the exit status of the last command in the list is zero, executes
  450. the
  451. .B do
  452. .IR list ;
  453. otherwise the loop terminates.
  454. If no commands in the
  455. .B do
  456. .I list\^
  457. are executed, then the
  458. .B while
  459. command returns a zero exit status;
  460. .B until
  461. may be used in place of
  462. .B while
  463. to negate
  464. the loop termination test.
  465. .TP
  466. \f3(\fP\f2list\^\fP\f3)\fP
  467. .br
  468. Execute
  469. .I list\^
  470. in a separate environment.
  471. Note, that if two adjacent open parentheses are
  472. needed for nesting, a space must be inserted to avoid
  473. evaluation as an arithmetic command as described above.
  474. .TP
  475. \f3{ \fP\f2list\^\fP\f3;}\fP
  476. .br
  477. .I list\^
  478. is simply executed.
  479. Note that unlike the metacharacters
  480. .B (
  481. and
  482. .BR ) ,
  483. .B {
  484. and
  485. .B }
  486. are
  487. .IR "reserved word" s
  488. and must occur
  489. at the beginning of a line or after a
  490. .B ;
  491. in order to be recognized.
  492. .TP
  493. \f3[[\fP\f2 expression \^\fP\f3]]\fP
  494. .br
  495. Evaluates
  496. .I expression\^
  497. and returns a zero exit status when
  498. .I expression\^
  499. is true.
  500. See
  501. .I "Conditional Expressions\^"
  502. below, for a description of
  503. .IR expression .
  504. .TP
  505. .PD 0
  506. \f3function\fP \f2varname\^\fP \f3{\fP \f2list\^\fP \f3;}\fP
  507. .TP
  508. \f2varname\^\fP \f3() {\fP \f2list\^\fP \f3;}\fP
  509. .PD
  510. Define a function which is referenced by
  511. .IR varname .
  512. A function whose
  513. .I varname\^
  514. contains a
  515. .B \s+2.\s-2
  516. is called a discipline function and the portion
  517. of the
  518. .I varname\^
  519. preceding the last
  520. .B \s+2.\s-2
  521. must refer to an existing variable.
  522. The body of the function is the
  523. .I list\^
  524. of commands between
  525. .B {
  526. and
  527. .BR } .
  528. A function defined with the \f3function\fP \f2varname\^\fP
  529. syntax can also be used as an argument to the \f3.\fP
  530. special built-in command to get the equivalent behavior
  531. as if the \f2varname\^\fP\f3()\fP syntax were used to define it.
  532. (See
  533. .I Functions\^
  534. below.)
  535. .TP
  536. \f3time\fP \*(OK \f2pipeline\^\fP \*(CK
  537. .br
  538. If \f2pipeline\^\fP is omitted the user and system time for
  539. the current shell and completed child processes is printed
  540. on standard error.
  541. Otherwise,
  542. .I pipeline\^
  543. is executed and the elapsed time as well as
  544. the user and system time are printed on standard error.
  545. .PP
  546. The following reserved words
  547. are only recognized as such when they are the first word of a command
  548. and are not quoted:
  549. .if t .RS
  550. .PP
  551. .B
  552. .if n if then else elif fi case esac for while until do done { } function select time [[ ]] !
  553. .if t if then else elif fi case esac for while until do done { } function select time [[ ]] !
  554. .if t .RE
  555. .SS Variable Assignments.
  556. One or more variable assignments can start a simple command
  557. or can be an arguments to the
  558. .BR typeset ,
  559. .BR export ,
  560. or
  561. .B readonly
  562. special built-in commands.
  563. The syntax for an \f2assignment\^\fP is of the form:
  564. .TP
  565. .PD 0
  566. \f2varname\^\fP\f3=\fP\f2word\^\fP
  567. .TP
  568. \f2varname\^\fP\f3[\fP\f2word\^\fP\f3]\fP=\fP\f2word\^\fP
  569. .PD
  570. No space is permitted between \f2varname\^\fP and the \f3=\fP or
  571. between \f3=\fP and \fIword\^\fP.
  572. .TP
  573. \f2varname\^\fP\f3=(\fP\f2assign_list\^\fP\f3)\fP
  574. No space is permitted between \f2varname\^\fP and the \f3=\fP.
  575. An \f2assign_list\^\fP can be one of the following:
  576. .RS 15
  577. .PD 0
  578. .TP
  579. \f2word\^\fP ...
  580. Indexed array assignment.
  581. .TP
  582. \f3[\fP\f2word\^\fP\f3]=\fP\f2word\^\fP .\|.\|.
  583. Associative array assignment.
  584. .TP
  585. \f2assignment\^\fP .\|.\|.
  586. Nested variable assignment.
  587. .TP
  588. \f3typeset\fP \*(OK\f2options\fP\*(CK \f2assignment\^\fP .\|.\|.
  589. Nested variable assignment. Multiple assignments
  590. can be specified by separating each of them with a \f3;\fP.
  591. .PD
  592. .RE
  593. .SS Comments.
  594. .PD 0
  595. A word beginning with
  596. .B #
  597. causes that word and all the following characters up to a new-line
  598. to be ignored.
  599. .SS Aliasing.
  600. The first word of each command is replaced by the text of an
  601. .B alias
  602. if an
  603. .B alias
  604. for this word has been defined.
  605. An
  606. .B alias
  607. name consists of any number of characters excluding metacharacters,
  608. quoting characters,
  609. file expansion characters,
  610. parameter expansion and command substitution
  611. characters,
  612. and
  613. .BR = .
  614. The replacement string can contain any
  615. valid shell script
  616. including the metacharacters listed above.
  617. The first word of each command in the
  618. replaced text,
  619. other than
  620. any that are in the process of being replaced,
  621. will be tested for aliases.
  622. If the last character of the alias value is a
  623. .I blank\^
  624. then the word following the alias will also be checked for alias
  625. substitution.
  626. Aliases can be used to redefine
  627. built-in commands but cannot be used to redefine
  628. the reserved words listed above.
  629. Aliases can be created and listed with the
  630. .B alias
  631. command and can be removed with the
  632. .B unalias
  633. command.
  634. .PP
  635. .I Aliasing\^
  636. is performed when
  637. scripts are read,
  638. not while they are executed.
  639. Therefore,
  640. for an alias to take effect
  641. the
  642. .B
  643. alias
  644. definition command has to be executed before
  645. the command which references the alias is read.
  646. .PP
  647. The following
  648. .I exported aliases
  649. are compiled into the shell
  650. but can be unset or redefined:
  651. .RS 20
  652. .PD 0
  653. .TP
  654. .B "autoload=\(fmtypeset \-fu\(fm"
  655. .TP
  656. .B "command=\(fmcommand \(fm"
  657. .TP
  658. .B "fc=hist"
  659. .TP
  660. .B "float=\(fmtypeset \-E\(fm"
  661. .TP
  662. .B "functions=\(fmtypeset \-f\(fm"
  663. .TP
  664. .B "hash=\(fmalias \-t \-\-\(fm"
  665. .TP
  666. .B "history=\(fmhist \-l\(fm"
  667. .TP
  668. .B "integer=\(fmtypeset \-i\(fm"
  669. .TP
  670. .B "nameref=\(fmtypeset \-n\(fm"
  671. .TP
  672. .B "nohup=\(fmnohup \(fm"
  673. .TP
  674. .B "r=\(fmhist \-s\(fm"
  675. .TP
  676. .B "redirect=\(fmcommand exec\(fm"
  677. .TP
  678. .B "stop=\(fmkill \-s \s-1STOP\s+1\(fm"
  679. .TP
  680. .B "times=\(fm{ {time;} 2>&1;}\(fm"
  681. .TP
  682. .B "type=\(fmwhence \-v\(fm"
  683. .PD
  684. .RE
  685. .SS Tilde Substitution.
  686. After alias substitution is performed, each word
  687. is checked to see if it begins with an unquoted
  688. .BR \(ap .
  689. For tilde substitution,
  690. .I word\^
  691. also refers to the
  692. .I word\^
  693. portion of parameter expansion
  694. ( see
  695. .I "Parameter Expansion\^"
  696. below.)
  697. If it does, then the word up to a
  698. .B /
  699. is checked to see if it matches a user name in the
  700. password database (
  701. often the
  702. .B /etc/passwd
  703. file).
  704. If a match is found, the
  705. .B \(ap
  706. and the matched login name are replaced by the
  707. login directory of the matched user.
  708. If no match is found, the original text is left unchanged.
  709. A
  710. .B \(ap
  711. by itself, or in front of a
  712. .BR / ,
  713. is replaced by
  714. .SM
  715. .BR $HOME .
  716. A
  717. .B \(ap
  718. followed by a
  719. .B +
  720. or
  721. .B \-
  722. is replaced by the value of
  723. .B
  724. .SM $PWD
  725. and
  726. .B
  727. .SM $OLDPWD
  728. respectively.
  729. .PP
  730. In addition,
  731. when expanding a
  732. .IR "variable assignment" ,
  733. .I tilde
  734. substitution is attempted when
  735. the value of the assignment
  736. begins with a
  737. .BR \(ap ,
  738. and when a
  739. .B \(ap
  740. appears after a
  741. .BR : .
  742. The
  743. .B :
  744. also terminates a
  745. .B \(ap
  746. login name.
  747. .if \nY=1 \{.PP
  748. On R&D UNIX Systems with RFS, an additional capability,
  749. .BR \(aphost!user ,
  750. has been added to
  751. .IR ksh .
  752. See
  753. .IR logdir (1)
  754. for a complete description of the capability.\}
  755. .SS Command Substitution.
  756. The standard output from a command enclosed in
  757. parentheses preceded by a dollar sign (
  758. .B $(\|)
  759. )
  760. or a pair of grave accents (\^\f3\*`\^\*`\fP\^)
  761. may be used as part or all
  762. of a word;
  763. trailing new-lines are removed.
  764. In the second (obsolete) form, the string between the quotes is processed
  765. for special quoting characters before the command is executed (see
  766. .I Quoting\^
  767. below).
  768. The command substitution
  769. \^\f3$(\^cat file\^)\fP\^
  770. can be replaced by the equivalent but faster
  771. \^\f3$(\^<file\^)\fP\^.
  772. .SS Arithmetic Substitution.
  773. An arithmetic expression enclosed in double
  774. parentheses preceded by a dollar sign (
  775. .B $((\|))
  776. )
  777. is replaced by the value of the arithmetic expression
  778. within the double parentheses.
  779. .SS Process Substitution.
  780. This feature is only available on
  781. versions of the UNIX operating system that support the
  782. .B /dev/fd
  783. directory for naming open files.
  784. Each command argument of the form
  785. \f3<(\fP\f2list\^\fP\f3)\fP
  786. or
  787. \f3>(\fP\f2list\^\fP\f3)\fP
  788. will run process
  789. .I list
  790. asynchronously connected to some file in
  791. .BR /dev/fd .
  792. The name of this file will become the argument to the command.
  793. If the form with
  794. .B >
  795. is selected then writing on this file will provide input for
  796. .IR list .
  797. If
  798. .B <
  799. is used,
  800. then the file passed as an argument will contain the output of the
  801. .I list
  802. process.
  803. For example,
  804. .RS
  805. .PP
  806. \f3paste <(cut \-f1\fP \f2file1\fP\f3) <(cut \-f3\fP \f2file2\f3) | tee >(\fP\f2process1\fP\f3) >(\fP\f2process2\fP\f3)\fP
  807. .RE
  808. .PP
  809. .I cuts
  810. fields 1 and 3 from
  811. the files
  812. .I file1
  813. and
  814. .I file2
  815. respectively,
  816. .I pastes
  817. the results together, and
  818. sends it
  819. to the processes
  820. .I process1
  821. and
  822. .IR process2 ,
  823. as well as putting it onto the standard output.
  824. Note that the file, which is passed as an argument to the command,
  825. is a UNIX
  826. .IR pipe (2)
  827. so programs that expect to
  828. .IR lseek (2)
  829. on the file will not work.
  830. .SS Parameter Expansion.
  831. A
  832. .I parameter\^
  833. is an
  834. .IR variable ,
  835. one or more digits,
  836. or any of the characters
  837. .BR \(** ,
  838. .BR @ ,
  839. .BR # ,
  840. .BR ? ,
  841. .BR \- ,
  842. .BR $ ,
  843. and
  844. .BR !\\^ .
  845. A
  846. .I variable\^
  847. is denoted by a \f2vname\fP.
  848. To create a variable whose
  849. .I vname\^
  850. contains a \f3\s+2.\s-2\fP,
  851. a variable whose
  852. .I vname\^
  853. consists of everything before the last \f3\s+2.\s-2\fP must already exist.
  854. A
  855. .I variable\^
  856. has a
  857. .I value\^
  858. and zero or more
  859. .IR attributes .
  860. .I Variables\^
  861. can be assigned
  862. .I values\^
  863. and
  864. .I attributes
  865. by using the
  866. .B typeset\^
  867. special built-in command.
  868. The attributes supported by the shell are described
  869. later with the
  870. .B typeset\^
  871. special built-in command.
  872. Exported variables pass values and attributes to
  873. the environment.
  874. .PP
  875. The shell supports both indexed and associative arrays.
  876. An element of an array variable is referenced by a
  877. .IR subscript .
  878. A
  879. .I subscript\^
  880. for an indexed array is denoted by
  881. an
  882. .I arithmetic expression\^
  883. (see
  884. .I "Arithmetic evaluation"
  885. below)
  886. between a
  887. .B [
  888. and a
  889. .BR ] .
  890. To assign values to an indexed array, use
  891. \f3set \-A\fP \f2vname\fP \f2value\fP .\|.\|. .
  892. The value of all
  893. subscripts must be in the
  894. range of
  895. 0 through 4095.
  896. Indexed arrays need not be declared.
  897. Any reference to a variable
  898. with a valid subscript is
  899. legal and an array will be created if necessary.
  900. .PP
  901. An associative array is created with the
  902. .B \-A
  903. option to
  904. .BR typeset.
  905. A
  906. .I subscript\^
  907. for an associative array is denoted by
  908. a string enclosed between
  909. .B [
  910. and
  911. .BR ] .
  912. .PP
  913. Referencing any array without a subscript
  914. is equivalent to referencing the array with subscript 0.
  915. .PP
  916. The
  917. .I value\^
  918. of a
  919. .I variable\^
  920. may be assigned by writing:
  921. .RS
  922. .PP
  923. .IB vname = value\^\|
  924. \*(OK
  925. .IB vname = value\^
  926. \*(CK .\|.\|.
  927. .RE
  928. .PP
  929. .PD 0
  930. or
  931. .RS
  932. .PP
  933. .IB vname [ subscript ]= value\^\|
  934. \*(OK
  935. .IB vname [ subscript ]= value\^
  936. \*(CK .\|.\|.
  937. .RE
  938. Note that no space is allowed before or after the
  939. .BR = .
  940. .PP
  941. .PD 0
  942. A
  943. .I nameref\^
  944. is a variable that is a reference to another variable.
  945. A nameref is created with the
  946. .B \-n
  947. attribute of
  948. .B typeset .
  949. The value of the variable at the time of the
  950. .B typeset
  951. command becomes the variable that will be referenced whenever
  952. the nameref variable is used.
  953. The name of a nameref variable cannot contain a \fB\s+2.\s-2\fP.
  954. When a variable or function name contains a \fB\s+2.\s-2\fP, and the portion
  955. of the name up to the first \fB\s+2.\s-2\fP matches the
  956. name of a nameref, the variable referred to is obtained by
  957. replacing the nameref portion with the name of the variable
  958. referenced by the nameref.
  959. A nameref provides a convenient way to refer to the variable
  960. inside a function whose name is passed as an argument to a function.
  961. For example, if the name of a variable is passed as the first
  962. argument to a function, the command
  963. .RS
  964. .PP
  965. typeset \-n var=$1
  966. .RE
  967. .PP
  968. inside the function causes references and assignments to
  969. .B var
  970. to be references and assignments to the variable whose
  971. name has been passed to the function.
  972. .PP
  973. If either of the floating point attributes,
  974. .BR \-E ,
  975. or
  976. .BR \-F ,
  977. or the integer attribute,
  978. .BR \-i ,
  979. is set for
  980. .IR vname ,
  981. then the
  982. .I value\^
  983. is subject to arithmetic evaluation as described below.
  984. .PP
  985. Positional parameters,
  986. parameters denoted by a number,
  987. may be assigned values with the
  988. .B set\^
  989. special built-in command.
  990. Parameter
  991. .B $0
  992. is set from argument zero when the shell
  993. is invoked.
  994. .PP
  995. The character
  996. .B $
  997. is used to introduce substitutable
  998. .IR parameters .
  999. .TP
  1000. \f3${\fP\f2parameter\^\fP\f3}\fP
  1001. The shell
  1002. reads all the characters from
  1003. .B ${
  1004. to the matching
  1005. .B }
  1006. as part of the same word even if it contains
  1007. braces or metacharacters.
  1008. The value, if any, of the parameter is substituted.
  1009. The braces are required when
  1010. .I parameter\^
  1011. is followed by a letter, digit, or underscore
  1012. that is not to be interpreted as part of its name,
  1013. when the variable name contains a \fB\s+2.\s-2\fP,
  1014. or when a variable is subscripted.
  1015. If
  1016. .I parameter\^
  1017. is one or more digits then it is a positional parameter.
  1018. A positional parameter of more than one digit must be
  1019. enclosed in braces.
  1020. If
  1021. .I parameter\^
  1022. is
  1023. .B \(**
  1024. or
  1025. .BR @ ,
  1026. then all the positional
  1027. parameters, starting with
  1028. .BR $1 ,
  1029. are substituted
  1030. (separated by a field separator character).
  1031. If an array
  1032. .I vname\^
  1033. with subscript
  1034. .B \(**
  1035. or
  1036. .B @
  1037. is used,
  1038. then the value
  1039. for each of the
  1040. elements
  1041. is substituted
  1042. (separated by a field separator character).
  1043. .TP
  1044. \f3${#\fP\f2parameter\^\fP\f3}\fP
  1045. If
  1046. .I parameter\^
  1047. is
  1048. .B \(**
  1049. or
  1050. .BR @ ,
  1051. the number of positional parameters is substituted.
  1052. Otherwise, the length of the value of the
  1053. .I parameter\^
  1054. is substituted.
  1055. .TP
  1056. \f3${#\fP\f2vname\fP\f3[*]}\fP
  1057. The number of elements in the array
  1058. .I vname\^
  1059. is substituted.
  1060. .TP
  1061. \f3${!\fP\f2vname\^\fP\f3}\fP
  1062. Expands to the name of the variable referred to by
  1063. .IR vname .
  1064. This will be
  1065. .I vname\^
  1066. except when
  1067. .I vname\^
  1068. is a name reference.
  1069. .TP
  1070. \f3${!\fP\f2vname\^\fP\f3[\f2subscript\^\f3]}\fP
  1071. Expands to name of the subscript unless
  1072. .I subscript\^
  1073. is
  1074. .BR * ,
  1075. or
  1076. .BR @ .
  1077. When
  1078. .I subscript\^
  1079. is
  1080. .BR * ,
  1081. the list of array subscripts for \f2vname\^\fP
  1082. is generated.
  1083. For a variable that is not an array, the value is 0 if the variable
  1084. is set. Otherwise it is null.
  1085. When
  1086. .I subscript\^
  1087. is
  1088. .BR @ ,
  1089. same as above, except that when used in double quotes,
  1090. each array subscript yields a separate
  1091. argument.
  1092. .TP
  1093. \f3${!\fP\f2prefix\^\fP\f3*}\fP
  1094. Expands to the names of the variables whose names begin with
  1095. .IR prefix .
  1096. .TP
  1097. \f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
  1098. If
  1099. .I parameter\^
  1100. is set and is non-null then substitute its value;
  1101. otherwise substitute
  1102. .IR word .
  1103. .TP
  1104. \f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
  1105. If
  1106. .I parameter\^
  1107. is not set or is null then set it to
  1108. .IR word ;
  1109. the value of the parameter is then substituted.
  1110. Positional parameters may not be assigned to
  1111. in this way.
  1112. .TP
  1113. \f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
  1114. If
  1115. .I parameter\^
  1116. is set and is non-null then substitute its value;
  1117. otherwise, print
  1118. .I word\^
  1119. and exit from the shell.
  1120. If
  1121. .I word\^
  1122. is omitted then a standard message is printed.
  1123. .TP
  1124. \f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
  1125. If
  1126. .I parameter\^
  1127. is set and is non-null then substitute
  1128. .IR word ;
  1129. otherwise substitute nothing.
  1130. .TP
  1131. .PD 0
  1132. \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3:\fP\f2length\^\fP\f3}\fP
  1133. .TP
  1134. \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3}\fP
  1135. Expands to the portion of the value of
  1136. .I parameter\^
  1137. starting at the character determined by expanding
  1138. .I offset\^
  1139. as an arithmetic expression and consisting of the
  1140. number of characters determined by the arithmetic expression
  1141. defined by
  1142. .IR length.
  1143. In the second form, the remainder of the value is used.
  1144. If
  1145. .I parameter\^
  1146. is
  1147. .B \(**
  1148. or
  1149. .BR @ ,
  1150. or is an array name indexed by
  1151. .B \(**
  1152. or
  1153. .BR @ ,
  1154. then
  1155. .I offset\^
  1156. and
  1157. .I length\^
  1158. refer to the array index and number
  1159. of elements respectively.
  1160. .TP
  1161. .PD 0
  1162. \f3${\fP\f2parameter\^\fP\f3#\fP\f2pattern\^\fP\f3}\fP
  1163. .TP
  1164. \f3${\fP\f2parameter\^\fP\f3##\fP\f2pattern\^\fP\f3}\fP
  1165. .PD
  1166. If
  1167. the shell
  1168. .I pattern\^
  1169. matches the beginning of the value of
  1170. .IR parameter ,
  1171. then the value of
  1172. this expansion is the value of the
  1173. .I parameter\^
  1174. with the matched portion deleted;
  1175. otherwise the value of this
  1176. .I parameter\^
  1177. is substituted.
  1178. In the first form the smallest matching pattern is deleted and in the
  1179. second form the largest matching pattern is deleted.
  1180. When
  1181. .I parameter\^
  1182. is
  1183. .BR @ ,
  1184. .BR * ,
  1185. or an array variable with subscript
  1186. .BR @ ,
  1187. or
  1188. .BR * ,
  1189. the substring operation is applied to each element in turn.
  1190. .TP
  1191. .PD 0
  1192. \f3${\fP\f2parameter\^\fP\f3%\fP\f2pattern\^\fP\f3}\fP
  1193. .TP
  1194. \f3${\fP\f2parameter\^\fP\f3%%\fP\f2pattern\^\fP\f3}\fP
  1195. .PD
  1196. If
  1197. the shell
  1198. .I pattern\^
  1199. matches the end of the value of
  1200. .IR parameter ,
  1201. then the value of
  1202. this expansion is the value of the
  1203. .I parameter\^
  1204. with the matched part deleted;
  1205. otherwise substitute the value of
  1206. .IR parameter .
  1207. In the first form the smallest matching pattern is deleted and in the
  1208. second form the largest matching pattern is deleted.
  1209. When
  1210. .I parameter\^
  1211. is
  1212. .BR @ ,
  1213. .BR * ,
  1214. or an array variable with subscript
  1215. .BR @ ,
  1216. or
  1217. .BR * ,
  1218. the substring operation is applied to each element in turn.
  1219. .TP
  1220. .PD 0
  1221. \f3${\fP\f2parameter\^\fP\f3/\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
  1222. .TP
  1223. \f3${\fP\f2parameter\^\fP\f3//\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
  1224. .PD
  1225. Expands
  1226. .I parameter\^
  1227. and replaces
  1228. .I pattern\^
  1229. with the given
  1230. .IR string.
  1231. In the first form,
  1232. only the first occurrence of
  1233. .I pattern\^
  1234. is replaced.
  1235. In the second form,
  1236. each match for
  1237. .I pattern\^
  1238. is replaced by the given
  1239. .IR string.
  1240. When
  1241. .I string\^
  1242. is null, the
  1243. .I pattern\^
  1244. will be deleted and the
  1245. .B /
  1246. in front of
  1247. .I string\^
  1248. may be omitted.
  1249. When
  1250. .I parameter\^
  1251. is
  1252. .BR @ ,
  1253. .BR * ,
  1254. or an array variable with subscript
  1255. .BR @ ,
  1256. or
  1257. .BR * ,
  1258. the substitution operation is applied to each element in turn.
  1259. .PP
  1260. In the above,
  1261. .I word\^
  1262. is not evaluated unless it is
  1263. to be used as the substituted string,
  1264. so that, in the following example,
  1265. .B pwd\^
  1266. is executed only if
  1267. .B d\^
  1268. is not set or is null:
  1269. .RS
  1270. .PP
  1271. print \|${d:\-\^$(\^pwd\^)\^}
  1272. .RE
  1273. .PP
  1274. If the colon (
  1275. .B : )
  1276. is omitted from the above expressions,
  1277. then the shell only checks whether
  1278. .I parameter\^
  1279. is set or not.
  1280. .PP
  1281. The following
  1282. parameters
  1283. are automatically set by the shell:
  1284. .RS
  1285. .PD 0
  1286. .TP
  1287. .B #
  1288. The number of positional parameters in decimal.
  1289. .TP
  1290. .B \-
  1291. Options supplied to the shell on invocation or by
  1292. the
  1293. .B set
  1294. command.
  1295. .TP
  1296. .B ?
  1297. The decimal value returned by the last executed command.
  1298. .TP
  1299. .B $
  1300. The process number of this shell.
  1301. .TP
  1302. .B _
  1303. Initially, the value of
  1304. .B _
  1305. is an absolute pathname of the shell or script being executed
  1306. as passed in the
  1307. .IR environment .
  1308. Subsequently it is assigned the last argument of the previous command.
  1309. This parameter is not set for commands which are asynchronous.
  1310. This parameter is also used to hold the name of the matching
  1311. .B
  1312. .SM MAIL
  1313. file when checking for mail.
  1314. .TP
  1315. .B !
  1316. The process number of the last background command invoked.
  1317. .TP
  1318. .B .sh.edchar
  1319. This variable contains the value of the keyboard character
  1320. (or sequence of characters if the first character is an ESC, ascii
  1321. .B 033 )
  1322. that has
  1323. been entered when processing a
  1324. .B
  1325. .SM KEYBD
  1326. trap.
  1327. If the value is changed as part of the trap action, then the new
  1328. value replaces the key (or key sequence) that caused the trap.
  1329. .TP
  1330. .B .sh.edcol
  1331. The character position of the cursor at the time of the most recent
  1332. .B
  1333. .SM KEYBD
  1334. trap.
  1335. .TP
  1336. .B .sh.edmode
  1337. The value is set to ESC when processing a
  1338. .B
  1339. .SM KEYBD
  1340. trap while in
  1341. .B vi
  1342. insert mode. (See
  1343. .I "Vi Editing Mode"\^
  1344. below.)
  1345. Otherwise,
  1346. .B .sh.edmode
  1347. is null when processing a
  1348. .B
  1349. .SM KEYBD
  1350. trap.
  1351. .TP
  1352. .B .sh.edtext
  1353. The characters in the input buffer at the time of the most recent
  1354. .B
  1355. .SM KEYBD
  1356. trap.
  1357. The value is null when not processing a
  1358. .B
  1359. .SM KEYBD
  1360. trap.
  1361. .TP
  1362. .B .sh.name
  1363. Set to the name of the variable at the time of a
  1364. .B set
  1365. or
  1366. .B get
  1367. discipline is invoked.
  1368. .TP
  1369. .B .sh.subscript
  1370. Set to the name subscript of the variable at the time of a
  1371. .B set
  1372. or
  1373. .B get
  1374. discipline is invoked.
  1375. .TP
  1376. .B .sh.value
  1377. Set to the value of the variable at the time of a
  1378. .B set
  1379. discipline.
  1380. .TP
  1381. .B .sh.version
  1382. Set to a value that identifies the version of this shell.
  1383. .TP
  1384. .B
  1385. .SM LINENO
  1386. The line number of the current line within the script or
  1387. function being executed.
  1388. .TP
  1389. .B
  1390. .SM OLDPWD
  1391. The previous working directory set by the
  1392. .B cd
  1393. command.
  1394. .TP
  1395. .B
  1396. .SM OPTARG
  1397. The value of the last option argument processed by the
  1398. .B getopts
  1399. built-in command.
  1400. .TP
  1401. .B
  1402. .SM OPTIND
  1403. The index of the last option argument processed by the
  1404. .B getopts
  1405. built-in command.
  1406. .TP
  1407. .B
  1408. .SM PPID
  1409. The process number of the parent of the shell.
  1410. .TP
  1411. .B
  1412. .SM PWD
  1413. The present working directory set by the
  1414. .B cd
  1415. command.
  1416. .TP
  1417. .B
  1418. .SM RANDOM
  1419. Each time this variable is referenced, a random integer,
  1420. uniformly distributed between 0 and 32767, is generated.
  1421. The sequence of random numbers can be initialized by assigning
  1422. a numeric value to
  1423. .SM
  1424. .BR RANDOM .
  1425. .TP
  1426. .B
  1427. .SM REPLY
  1428. This variable is set by the
  1429. .B select
  1430. statement and by
  1431. the
  1432. .B read
  1433. built-in command when no arguments are supplied.
  1434. .TP
  1435. .B
  1436. .SM SECONDS
  1437. Each time this variable is referenced, the number of
  1438. seconds since shell invocation is returned.
  1439. If this variable is
  1440. assigned a value, then the value returned upon reference will
  1441. be the value that was assigned plus the number of seconds since the assignment.
  1442. .PD
  1443. .RE
  1444. .PP
  1445. The following
  1446. variables
  1447. are used by the shell:
  1448. .RS
  1449. .PD 0
  1450. .TP
  1451. .B
  1452. .SM CDPATH
  1453. The search path for the
  1454. .B cd
  1455. command.
  1456. .TP
  1457. .B
  1458. .SM COLUMNS
  1459. If this variable is set,
  1460. the value is used to define the width of the edit window
  1461. for the shell edit modes and for printing
  1462. .B select
  1463. lists.
  1464. .TP
  1465. .B
  1466. .SM EDITOR
  1467. If the value of this variable ends in
  1468. .IR emacs ,
  1469. .IR gmacs ,
  1470. or
  1471. .I vi
  1472. and the
  1473. .B
  1474. .SM VISUAL
  1475. variable is not set,
  1476. then the corresponding option
  1477. (see Special Command
  1478. .B set
  1479. below)
  1480. will be turned on.
  1481. .TP
  1482. .SM
  1483. .B ENV
  1484. If this variable is set, then
  1485. parameter expansion, command substitution, and arithmetic substitution,
  1486. are performed on
  1487. the value to generate
  1488. the pathname of the script that will be
  1489. executed when the shell
  1490. is invoked.
  1491. (See
  1492. .I Invocation\^
  1493. below.)
  1494. This file is typically used for
  1495. .I alias
  1496. and
  1497. .I function
  1498. definitions.
  1499. .TP
  1500. .B
  1501. .SM FCEDIT
  1502. Obsolete name for
  1503. the default editor name for the
  1504. .B hist
  1505. command.
  1506. .B
  1507. .SM FCEDIT
  1508. is not used when
  1509. .B
  1510. .SM HISTEDIT
  1511. is set.
  1512. .TP
  1513. .SM
  1514. .B FIGNORE
  1515. A pattern that defines the set of filenames that will be
  1516. ignored when performing filename matching.
  1517. .TP
  1518. .SM
  1519. .B FPATH
  1520. The search path for function definitions.
  1521. This path is searched when a function with the
  1522. .B \-u
  1523. attribute is referenced and when a command is not found.
  1524. If an executable file is found, then it is read and executed
  1525. in the current environment.
  1526. .TP
  1527. .SM
  1528. .B IFS
  1529. Internal field separators,
  1530. normally
  1531. .BR space ,
  1532. .BR tab ,
  1533. and
  1534. .B new-line
  1535. that are used to separate the results of
  1536. command substitution or parameter expansion
  1537. and to separate fields with the built-in command
  1538. .BR read .
  1539. The first character of the
  1540. .SM
  1541. .B IFS
  1542. variable is used to separate arguments for the
  1543. .B
  1544. "$\(**"
  1545. substitution. (See
  1546. .I Quoting
  1547. below.)
  1548. Each single occurrence of
  1549. an
  1550. .SM
  1551. .B IFS
  1552. character in the string to be split,
  1553. except
  1554. .BR space ,
  1555. .BR tab ,
  1556. and
  1557. .BR new-line ,
  1558. separates a field.
  1559. One or more
  1560. .BR space ,
  1561. .BR tab ,
  1562. or
  1563. .B new-line
  1564. characters separate a field.
  1565. .TP
  1566. .B
  1567. .SM HISTEDIT
  1568. Name for
  1569. the default editor name for the
  1570. .B hist
  1571. command.
  1572. .TP
  1573. .SM
  1574. .B HISTFILE
  1575. If this variable is set when the shell is invoked, then
  1576. the value is the pathname of the file that will be
  1577. used to store the command history.
  1578. (See
  1579. .I "Command re-entry\^"
  1580. below.)
  1581. .TP
  1582. .SM
  1583. .B HISTSIZE
  1584. If this variable is set when the shell is invoked, then
  1585. the number of previously entered commands that
  1586. are accessible by this shell
  1587. will be greater than or equal to this number.
  1588. The default is 128.
  1589. .TP
  1590. .B
  1591. .SM HOME
  1592. The default argument (home directory) for the
  1593. .B cd
  1594. command.
  1595. .TP
  1596. .B
  1597. .SM LINES
  1598. If this variable is set,
  1599. the value is used to determine the column length for printing
  1600. .B select
  1601. lists.
  1602. Select lists will print vertically until about two-thirds of
  1603. .B
  1604. .SM LINES
  1605. lines are filled.
  1606. .TP
  1607. .B
  1608. .SM MAIL
  1609. If this variable is set to the name of a mail file
  1610. .I and\^
  1611. the
  1612. .B
  1613. .SM MAILPATH
  1614. variable is not set,
  1615. then the shell informs the user of arrival of mail
  1616. in the specified file.
  1617. .TP
  1618. .B
  1619. .SM MAILCHECK
  1620. This variable specifies how often (in seconds) the
  1621. shell will check for changes in the modification time
  1622. of any of the files specified by the
  1623. .B
  1624. .SM MAILPATH
  1625. or
  1626. .B
  1627. .SM MAIL
  1628. variables.
  1629. The default value is 600 seconds.
  1630. When the time has elapsed
  1631. the shell will check before issuing the next prompt.
  1632. .TP
  1633. .B
  1634. .SM MAILPATH
  1635. A colon (
  1636. .B :
  1637. )
  1638. separated list of file names.
  1639. If this variable is set
  1640. then the shell informs the user of
  1641. any modifications to the specified files
  1642. that have occurred within the last
  1643. .B
  1644. .SM MAILCHECK
  1645. seconds.
  1646. Each file name can be followed by a
  1647. .B ?
  1648. and a message that will be printed.
  1649. The message will undergo parameter expansion, command substitution,
  1650. and arithmetic substitution
  1651. with the variable
  1652. .B $_
  1653. defined as the name of the file that has changed.
  1654. The default message is
  1655. .I you have mail in $_\^.
  1656. .TP
  1657. .B
  1658. .SM PATH
  1659. The search path for commands (see
  1660. .I Execution\^
  1661. below).
  1662. The user may not change
  1663. .B \s-1PATH\s+1
  1664. if executing under
  1665. .if \nZ=0 .B rsh
  1666. .if \nZ=1 .B rksh
  1667. (except in
  1668. .BR .profile\^).
  1669. .TP
  1670. .SM
  1671. .B PS1
  1672. The value of this variable is expanded for parameter
  1673. expansion, command substitution, and arithmetic substitution to define the
  1674. primary prompt string which by default is
  1675. .RB `` "$\|\|\|" ''.
  1676. The character
  1677. .B !
  1678. in the primary prompt string is replaced by the
  1679. .I command\^
  1680. number (see
  1681. .I "Command Re-entry"\^
  1682. below).
  1683. Two successive occurrences of
  1684. .B !
  1685. will produce a single
  1686. .B !
  1687. when the prompt string is printed.
  1688. .TP
  1689. .SM
  1690. .B PS2
  1691. Secondary prompt string, by default
  1692. .RB `` "> \|" ''.
  1693. .TP
  1694. .SM
  1695. .B PS3
  1696. Selection prompt string
  1697. used within a
  1698. .B select
  1699. loop, by default
  1700. .RB `` "#? \|" ''.
  1701. .TP
  1702. .SM
  1703. .B PS4
  1704. The value of this variable is expanded for parameter evaluation,
  1705. command substitution, and arithmetic substitution
  1706. and precedes each line of an execution trace.
  1707. If omitted, the execution trace prompt is
  1708. .RB `` "+ \|" ''.
  1709. .TP
  1710. .SM
  1711. .B SHELL
  1712. The pathname of the
  1713. .I shell\^
  1714. is kept in the environment.
  1715. At invocation, if the basename of this variable is
  1716. .BR rsh ,
  1717. .BR rksh ,
  1718. or
  1719. .BR krsh ,
  1720. then the shell becomes restricted.
  1721. .TP
  1722. .B
  1723. .SM TMOUT
  1724. If set to a value greater than zero,
  1725. the
  1726. .B read
  1727. built-in command terminates after
  1728. .B
  1729. .SM TMOUT
  1730. seconds when input is from a terminal.
  1731. Otherwise,
  1732. the shell will terminate if a line is not entered within
  1733. the prescribed number of seconds while reading from a terminal.
  1734. (Note that the shell can be compiled with a maximum bound
  1735. for this value which cannot be exceeded.)
  1736. .TP
  1737. .B
  1738. .SM VISUAL
  1739. If the value of this variable ends in
  1740. .IR emacs ,
  1741. .IR gmacs ,
  1742. or
  1743. .I vi
  1744. then the corresponding option
  1745. (see Special Command
  1746. .B set
  1747. below)
  1748. will be turned on.
  1749. .PD
  1750. .RE
  1751. .PP
  1752. The shell gives default values to
  1753. \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP,
  1754. \f3\s-1PS3\s+1\fP, \f3\s-1PS4\s+1\fP, \f3\s-1MAILCHECK\s+1\fP, \f3\s-1HISTEDIT\s+1\fP,
  1755. \f3\s-1TMOUT\s+1\fP and \f3\s-1IFS\s+1\fP,
  1756. while
  1757. .SM
  1758. .BR HOME ,
  1759. .SM
  1760. .BR SHELL ,
  1761. .SM
  1762. .BR ENV ,
  1763. and
  1764. .SM
  1765. .B MAIL
  1766. are
  1767. not set at all by the shell (although
  1768. .SM
  1769. .B HOME
  1770. .I is\^
  1771. set by
  1772. .IR login (1)).
  1773. On some systems
  1774. .SM
  1775. .B MAIL
  1776. and
  1777. .SM
  1778. .B SHELL
  1779. are also
  1780. set by
  1781. .IR login (1).
  1782. .SS Field Splitting
  1783. After parameter expansion and command substitution,
  1784. the results of substitutions are scanned for the field separator
  1785. characters (those found in
  1786. .SM
  1787. .B IFS\^\c
  1788. )
  1789. and split into distinct fields where such characters are found.
  1790. Explicit null fields (\^\f3"\^"\fP or \f3\*\(fm\^\*\(fm\fP\^) are retained.
  1791. Implicit null fields
  1792. (those resulting from
  1793. .I parameters\^
  1794. that have no values or command substitutions with no output) are removed.
  1795. .SS File Name Generation.
  1796. Following splitting, each field is scanned for the characters
  1797. .BR \(** ,
  1798. .BR ? ,
  1799. .BR ( ,
  1800. and
  1801. .B \*(OK\^
  1802. unless the
  1803. .B \-f
  1804. option has been set.
  1805. If one of these characters appears
  1806. then the word is regarded as a
  1807. .IR pattern .
  1808. Each file name component that contains any pattern character
  1809. is replaced with a lexicographically sorted set of names
  1810. that matches the pattern
  1811. from
  1812. that directory.
  1813. If no file name is found that matches the pattern, then
  1814. that component of the filename is left unchanged.
  1815. If
  1816. .SM
  1817. .B FIGNORE
  1818. is set,
  1819. then each file name component
  1820. that matches the pattern defined by the value of
  1821. .SM
  1822. .B FIGNORE
  1823. is ignored when generating the matching filenames.
  1824. The names
  1825. .B .
  1826. and
  1827. .B ..
  1828. are also ignored.
  1829. If
  1830. .SM
  1831. .B FIGNORE
  1832. is not set,
  1833. the character
  1834. .B .
  1835. at the start of each file name component
  1836. will be ignored unless the first character of the pattern
  1837. corresponding to this component is the character
  1838. .BR .
  1839. itself.
  1840. Note, that for other
  1841. uses of pattern matching the
  1842. .B /
  1843. and
  1844. .B .
  1845. are not treated specially.
  1846. .PP
  1847. .PD 0
  1848. .RS
  1849. .TP
  1850. .B \(**
  1851. Matches any string, including the null string.
  1852. .TP
  1853. .B ?
  1854. Matches any single character.
  1855. .TP
  1856. .BR \*(OK \^.\|.\|.\^ \*(CK
  1857. Matches any one of the enclosed characters.
  1858. A pair of characters separated by
  1859. .B \-
  1860. matches any
  1861. character lexically between the pair, inclusive.
  1862. If the first character following the opening
  1863. .B \*(OK\^
  1864. is a
  1865. .B !
  1866. then any character not enclosed is matched.
  1867. A
  1868. .B \-
  1869. can be included in the character set by putting it as the
  1870. first or last character.
  1871. .br
  1872. Within
  1873. .B \*(OK\^
  1874. and
  1875. .B \*(CK\^
  1876. character classes can be specified with the syntax
  1877. \f3[:\fP\f2class\fP\f3:]\fP
  1878. where class is one of the following:
  1879. .if t .RS
  1880. .PP
  1881. .B
  1882. .if n alnum alpha cntrl digit graph lower print punct space upper xdigit
  1883. .if t alnum alpha cntrl digit graph lower print punct space upper xdigit
  1884. .if t .RE
  1885. .PD
  1886. .RE
  1887. A
  1888. .I pattern-list
  1889. is a list of one or more patterns separated from each other
  1890. with a
  1891. .BR \(bv .
  1892. Composite patterns can be formed with one or more of the following:
  1893. .PD 0
  1894. .RS
  1895. .TP
  1896. \f3?(\fP\f2pattern-list\^\fP\f3)\fP
  1897. Optionally matches any one of the given patterns.
  1898. .TP
  1899. \f3*(\fP\f2pattern-list\^\fP\f3)\fP
  1900. Matches zero or more occurrences of the given patterns.
  1901. .TP
  1902. \f3+(\fP\f2pattern-list\^\fP\f3)\fP
  1903. Matches one or more occurrences of the given patterns.
  1904. .TP
  1905. \f3\&@\&(\fP\f2pattern-list\^\fP\f3)\fP
  1906. Matches exactly one of the given patterns.
  1907. .br
  1908. .TP
  1909. \f3!(\fP\f2pattern-list\^\fP\f3)\fP
  1910. Matches anything except one of the given patterns.
  1911. .PD
  1912. .RE
  1913. .SS Quoting.
  1914. Each of the
  1915. .I metacharacters\^
  1916. listed earlier (see
  1917. .I Definitions\^
  1918. above)
  1919. has a special meaning to the shell
  1920. and causes termination of a word unless quoted.
  1921. A character may be
  1922. .I quoted\^
  1923. (i.e., made to stand for itself)
  1924. by preceding
  1925. it with a
  1926. .BR \e .
  1927. The pair
  1928. .B \enew-line
  1929. is removed.
  1930. All characters enclosed between a pair of single quote marks
  1931. (\^\f3\(fm\^\(fm\fP\^)
  1932. that is not preceded by a
  1933. .B $
  1934. are quoted.
  1935. A single quote cannot appear within the single quotes.
  1936. A single quoted string preceded an unquoted
  1937. .B $
  1938. is processed as an ANSI-C string
  1939. except that
  1940. .B \e0
  1941. within the string causes the remainder of the
  1942. string to be ignored and
  1943. .B \eE
  1944. is equivalent to the escape characer
  1945. (ascii
  1946. .BR 033 ).
  1947. Inside double quote marks
  1948. (\f3"\^"\fP),
  1949. parameter and command substitution occur and
  1950. .B \e
  1951. quotes the characters
  1952. .BR \e ,
  1953. .BR \*` ,
  1954. \f3"\fP,
  1955. and
  1956. .BR $ .
  1957. The meaning of
  1958. .B "$\(**"
  1959. and
  1960. .B "$@"
  1961. is identical when not quoted or when used as a variable assignment value
  1962. or as a file name.
  1963. However, when used as a command argument,
  1964. .B
  1965. "$\(**"
  1966. is equivalent to
  1967. \f3"$1\fP\f2d\fP\f3\|$2\fP\f2d\fP\|.\|.\|.\f3"\fP,
  1968. where
  1969. .I d
  1970. is the first character of the
  1971. .SM
  1972. .B IFS
  1973. variable, whereas
  1974. .B
  1975. "$@"
  1976. is equivalent to
  1977. .B
  1978. "$1"\|
  1979. .B
  1980. "$2"\|
  1981. \&.\|.\|.\^.
  1982. Inside grave quote marks
  1983. (\f3\*`\^\*`\fP),
  1984. .B \e
  1985. quotes the characters
  1986. .BR \e ,
  1987. .BR \*` ,
  1988. and
  1989. .BR $ .
  1990. If the grave quotes occur within double quotes then
  1991. .B \e
  1992. also quotes the character
  1993. \f3"\fP.
  1994. .PP
  1995. The special meaning of reserved words or aliases can be removed by quoting any
  1996. character of the reserved word.
  1997. The recognition of function names or built-in command names listed below
  1998. cannot be altered by quoting them.
  1999. .SS Arithmetic Evaluation.
  2000. The shell performs arithmetic evaluation for
  2001. arithmetic substitution, to evaluate an arithmetic command,
  2002. to evaluate an indexed array subscript,
  2003. and to evaluate arguments to
  2004. the built-in commands
  2005. .B shift\^
  2006. and
  2007. .BR let .
  2008. Evaluations are performed using
  2009. double precision floating point
  2010. arithmetic.
  2011. Floating point constants follow the ANSI-C programming language
  2012. conventions.
  2013. Integer constants are of the form
  2014. \*(OK\f2base\f3#\^\f1\*(CK\f2n\^\fP
  2015. where
  2016. .I base\^
  2017. is a decimal number between two and sixty-four
  2018. representing the arithmetic base
  2019. and
  2020. .I n\^
  2021. is a number in that base.
  2022. The digits above 9 are represented
  2023. by the lower case characters, the upper case characters,
  2024. .BR @ ,
  2025. and
  2026. .B _
  2027. respectively.
  2028. For bases less than 36, upper and lower case
  2029. character can be used interchangeably.
  2030. If
  2031. .I base\^
  2032. is omitted
  2033. then base 10 is used.
  2034. .PP
  2035. An arithmetic expression uses the same syntax, precedence, and
  2036. associativity of
  2037. expression as the C language.
  2038. All the C language operators
  2039. that apply to floating point quantities can be used.
  2040. In addition, when the value of an arithmetic variable
  2041. or sub-expression can be represented as a long integer,
  2042. all C language integer arithmetic operations can be performed.
  2043. Variables can be referenced by name within an arithmetic expression
  2044. without using the parameter expansion syntax.
  2045. When a variable is referenced, its value is evaluated as
  2046. an arithmetic expression.
  2047. The following math library functions can be used with an arithmetic
  2048. expression:
  2049. .if t .RS
  2050. .PP
  2051. .B
  2052. .if n abs acos asin atan cos cosh exp int log sin sinh sqrt tan tanh
  2053. .if t abs acos asin atan cos cosh exp int log sin sinh sqrt tan tanh
  2054. .if t .RE
  2055. .PP
  2056. An internal representation of a
  2057. .I variable\^
  2058. as a double precision floating point can be specified with the
  2059. \f3\-E\fP \*(OK\f2n\^\fP\*(CK
  2060. or
  2061. \f3\-F\fP \*(OK\f2n\^\fP\*(CK
  2062. option of the
  2063. .B typeset
  2064. special built-in command.
  2065. The
  2066. .B \-E
  2067. option causes the expansion of the value to be represented using
  2068. scientific notation when it is expanded.
  2069. The optional option argument
  2070. .I n
  2071. defines the number of significant figures.
  2072. The
  2073. .B \-F
  2074. option causes the expansion to be represented as a floating decimal number
  2075. when it is expanded.
  2076. The optional option argument
  2077. .I n
  2078. defines the number of places after the decimal point in this case.
  2079. .PP
  2080. An internal integer representation of a
  2081. .I variable\^
  2082. can be specified with the
  2083. \f3\-i\fP \*(OK\f2n\^\fP\*(CK
  2084. option of the
  2085. .B typeset
  2086. special built-in command.
  2087. The optional option argument
  2088. .I n
  2089. specifies an arithmetic base to be used when expanding the variable.
  2090. If you do not specify an arithmetic base,
  2091. the first assignment to the
  2092. variable determines the arithmetic base.
  2093. .PP
  2094. Arithmetic evaluation is performed on the value of each
  2095. assignment to a variable with the
  2096. .BR \-E ,
  2097. .BR \-F ,
  2098. or
  2099. .B \-i
  2100. attribute.
  2101. Assigning a floating point number to a
  2102. variable whose type is an integer causes the fractional
  2103. part to be truncated.
  2104. .PP
  2105. .SS Prompting.
  2106. When used interactively,
  2107. the shell prompts with the value of
  2108. .SM
  2109. .B PS1
  2110. after expanding it for parameter expansion, command substitution, and
  2111. arithmetic substitution,
  2112. before reading a command.
  2113. In addition, each single
  2114. .B !
  2115. in the prompt is replaced by the command number.
  2116. A
  2117. .B !!
  2118. is required to place
  2119. .B !
  2120. in the prompt.
  2121. If at any time a new-line is typed and further input is needed
  2122. to complete a command, then the secondary prompt
  2123. (i.e., the value of
  2124. .BR \s-1PS2\s+1 )
  2125. is issued.
  2126. .SS Conditional Expressions.
  2127. A
  2128. .I "conditional expression"
  2129. is used with the
  2130. .B [[
  2131. compound command to test attributes of files and to compare
  2132. strings.
  2133. Field splitting and file name generation are
  2134. not performed on the words between
  2135. .B [[
  2136. and
  2137. .BR ]] .
  2138. Each expression can be constructed from one or more
  2139. of the following unary or binary expressions:
  2140. .PD 0
  2141. .TP
  2142. \f2string\fP
  2143. True, if
  2144. .I string
  2145. is not null.
  2146. .TP
  2147. \f3\-a\fP \f2file\fP
  2148. Same is \f3\-e\fP below.
  2149. This is obsolete.
  2150. .TP
  2151. \f3\-b\fP \f2file\fP
  2152. True, if
  2153. .I file
  2154. exists and is a block special file.
  2155. .TP
  2156. \f3\-c\fP \f2file\fP
  2157. True, if
  2158. .I file
  2159. exists and is a character special file.
  2160. .TP
  2161. \f3\-d\fP \f2file\fP
  2162. True, if
  2163. .I file
  2164. exists and is a directory.
  2165. .TP
  2166. \f3\-e\fP \f2file\fP
  2167. True, if
  2168. .I file
  2169. exists.
  2170. .TP
  2171. \f3\-f\fP \f2file\fP
  2172. True, if
  2173. .I file
  2174. exists and is an ordinary file.
  2175. .TP
  2176. \f3\-g\fP \f2file\fP
  2177. True, if
  2178. .I file
  2179. exists and is has its setgid bit set.
  2180. .TP
  2181. \f3\-k\fP \f2file\fP
  2182. True, if
  2183. .I file
  2184. exists and is has its sticky bit set.
  2185. .TP
  2186. \f3\-n\fP \f2string\fP
  2187. True, if length of
  2188. .I string
  2189. is non-zero.
  2190. .TP
  2191. \f3\-o\fP \f2option\fP
  2192. True, if option named
  2193. .I option
  2194. is on.
  2195. .TP
  2196. \f3\-p\fP \f2file\fP
  2197. True, if
  2198. .I file
  2199. exists and is a fifo special file or a pipe.
  2200. .TP
  2201. \f3\-r\fP \f2file\fP
  2202. True, if
  2203. .I file
  2204. exists and is readable by current process.
  2205. .TP
  2206. \f3\-s\fP \f2file\fP
  2207. True, if
  2208. .I file
  2209. exists and has size greater than zero.
  2210. .TP
  2211. \f3\-t\fP \f2fildes\fP
  2212. True, if file descriptor number
  2213. .I fildes
  2214. is open and associated with a terminal device.
  2215. .TP
  2216. \f3\-u\fP \f2file\fP
  2217. True, if
  2218. .I file
  2219. exists and is has its setuid bit set.
  2220. .TP
  2221. \f3\-w\fP \f2file\fP
  2222. True, if
  2223. .I file
  2224. exists and is writable by current process.
  2225. .TP
  2226. \f3\-x\fP \f2file\fP
  2227. True, if
  2228. .I file
  2229. exists and is executable by current process.
  2230. If
  2231. .I file
  2232. exists and is a directory, then true if the current process
  2233. has permission to search in the directory.
  2234. .TP
  2235. \f3\-z\fP \f2string\fP
  2236. True, if length of
  2237. .I string
  2238. is zero.
  2239. .TP
  2240. \f3\-L\fP \f2file\fP
  2241. True, if
  2242. .I file
  2243. exists and is a symbolic link.
  2244. .TP
  2245. \f3\-O\fP \f2file\fP
  2246. True, if
  2247. .I file
  2248. exists and is owned by the effective user id of this process.
  2249. .TP
  2250. \f3\-G\fP \f2file\fP
  2251. True, if
  2252. .I file
  2253. exists and its group matches the effective group id of this process.
  2254. .TP
  2255. \f3\-S\fP \f2file\fP
  2256. True, if
  2257. .I file
  2258. exists and is a socket.
  2259. .TP
  2260. \f2file1\fP \f3\-nt\fP \f2file2\fP
  2261. True, if
  2262. .I file1
  2263. exists and is newer than
  2264. .IR file2 .
  2265. .TP
  2266. \f2file1\fP \f3\-ot\fP \f2file2\fP
  2267. True, if
  2268. .I file1
  2269. exists and is older than
  2270. .IR file2 .
  2271. .TP
  2272. \f2file1\fP \f3\-ef\fP \f2file2\fP
  2273. True, if
  2274. .I file1
  2275. and
  2276. .I file2
  2277. exist and refer to the same file.
  2278. .TP
  2279. \f2string\fP \f3==\fP \f2pattern\fP
  2280. True, if
  2281. .I string
  2282. matches
  2283. .IR pattern .
  2284. Any part of
  2285. .I pattern\^
  2286. can be quoted to cause it to be matched as a string.
  2287. .TP
  2288. \f2string\fP \f3=\fP \f2pattern\fP
  2289. Same as \f3==\fP above, but is obsolete.
  2290. .TP
  2291. \f2string\fP \f3!=\fP \f2pattern\fP
  2292. True, if
  2293. .I string
  2294. does not match
  2295. .IR pattern .
  2296. .TP
  2297. \f2string1\fP \f3<\fP \f2string2\fP
  2298. True, if
  2299. .I string1
  2300. comes before
  2301. .I string2
  2302. based on ASCII value of their characters.
  2303. .TP
  2304. \f2string1\fP \f3>\fP \f2string2\fP
  2305. True, if
  2306. .I string1
  2307. comes after
  2308. .I string2
  2309. based on ASCII value of their characters.
  2310. .PP
  2311. The following obsolete arithmetic comparisons are also permitted:
  2312. .PD 0
  2313. .TP
  2314. \f2exp1\fP \f3\-eq\fP \f2exp2\fP
  2315. True, if
  2316. .I exp1
  2317. is equal to
  2318. .IR exp2 .
  2319. .TP
  2320. \f2exp1\fP \f3\-ne\fP \f2exp2\fP
  2321. True, if
  2322. .I exp1
  2323. is not equal to
  2324. .IR exp2 .
  2325. .TP
  2326. \f2exp1\fP \f3\-lt\fP \f2exp2\fP
  2327. True, if
  2328. .I exp1
  2329. is less than
  2330. .IR exp2 .
  2331. .TP
  2332. \f2exp1\fP \f3\-gt\fP \f2exp2\fP
  2333. True, if
  2334. .I exp1
  2335. is greater than
  2336. .IR exp2 .
  2337. .TP
  2338. \f2exp1\fP \f3\-le\fP \f2exp2\fP
  2339. True, if
  2340. .I exp1
  2341. is less than or equal to
  2342. .IR exp2 .
  2343. .TP
  2344. \f2exp1\fP \f3\-ge\fP \f2exp2\fP
  2345. True, if
  2346. .I exp1
  2347. is greater than or equal to
  2348. .IR exp2 .
  2349. .PD
  2350. .PP
  2351. In each of the above expressions, if
  2352. .I file
  2353. is of the form
  2354. \f3/dev/fd/\fP\f2n\fP,
  2355. where
  2356. .I n
  2357. is an integer,
  2358. then the test is applied to the open file whose
  2359. descriptor number is
  2360. .IR n .
  2361. .PP
  2362. A compound expression can be constructed from these primitives by
  2363. using any of the following, listed in decreasing order of precedence.
  2364. .PD 0
  2365. .TP
  2366. \f3(\fP\f2expression\fP\f3)\fP
  2367. True, if
  2368. .I expression
  2369. is true.
  2370. Used to group expressions.
  2371. .TP
  2372. \f3!\fP \f2expression\fP
  2373. True if
  2374. .I expression
  2375. is false.
  2376. .TP
  2377. \f2expression1\fP \f3&&\fP \f2expression2\fP
  2378. True, if
  2379. .I expression1
  2380. and
  2381. .I expression2
  2382. are both true.
  2383. .TP
  2384. \f2expression1\fP \f3\(bv\(bv\fP \f2expression2\fP
  2385. True, if either
  2386. .I expression1
  2387. or
  2388. .I expression2
  2389. is true.
  2390. .PD
  2391. .SS Input/Output.
  2392. Before a command is executed, its input and output
  2393. may be redirected using a special notation interpreted by the shell.
  2394. The following may appear anywhere in a simple-command
  2395. or may precede or follow a
  2396. .I command\^
  2397. and are
  2398. .I not\^
  2399. passed on to the invoked command.
  2400. Command substitution, parameter expansion,
  2401. and arithmetic substitution occur before
  2402. .I word\^
  2403. or
  2404. .I digit\^
  2405. is used except as noted below.
  2406. File name generation
  2407. occurs only if the shell is interactive and
  2408. the pattern matches a single file,
  2409. Field splitting is not performed.
  2410. .TP 14
  2411. .BI < word
  2412. Use file
  2413. .I word\^
  2414. as standard input (file descriptor 0).
  2415. .TP
  2416. .BI > word
  2417. Use file
  2418. .I word\^
  2419. as standard output (file descriptor 1).
  2420. If the file does not exist then it is created.
  2421. If the file exists, and the
  2422. .B noclobber
  2423. option is on,
  2424. this causes an error;
  2425. otherwise, it is truncated to zero length.
  2426. .TP
  2427. .BI >| word
  2428. Sames as
  2429. .BR > ,
  2430. except that it overrides the
  2431. .B noclobber
  2432. option.
  2433. .TP
  2434. .BI >> word
  2435. Use file
  2436. .I word\^
  2437. as standard output.
  2438. If the file exists then output is appended to it (by first seeking to the end-of-file);
  2439. otherwise, the file is created.
  2440. .TP
  2441. .BI <> word
  2442. Open file
  2443. .I word\^
  2444. for reading and writing
  2445. as standard input.
  2446. .TP
  2447. \f3<<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
  2448. The shell input is read up to a line that is the same as
  2449. .IR word
  2450. after any quoting has been removed remove,
  2451. or to an end-of-file.
  2452. No parameter substitution, command substitution, arithmetic substitution or
  2453. file name generation is performed on
  2454. .IR word .
  2455. The resulting document,
  2456. called a
  2457. .IR here-document ,
  2458. becomes
  2459. the standard input.
  2460. If any character of
  2461. .I word\^
  2462. is quoted, then no interpretation
  2463. is placed upon the characters of the document;
  2464. otherwise, parameter expansion, command substitution, and arithmetic
  2465. substitution occur,
  2466. .B \enew-line
  2467. is ignored,
  2468. and
  2469. .B \e
  2470. must be used to quote the characters
  2471. .BR \e ,
  2472. .BR $ ,
  2473. .BR \*` .
  2474. If
  2475. .B \-
  2476. is appended to
  2477. .BR << ,
  2478. then all leading tabs are stripped from
  2479. .I word\^
  2480. and from the document.
  2481. .TP
  2482. .BI <& digit
  2483. The standard input is duplicated from file descriptor
  2484. .I digit
  2485. (see
  2486. .IR dup (2)).
  2487. Similarly for the standard output using
  2488. \f3>&\^\f2digit\fR.
  2489. .TP
  2490. .B <&\-
  2491. The standard input is closed.
  2492. Similarly for the standard output using
  2493. .BR >&\- .
  2494. .TP
  2495. .B <&p
  2496. The input from the co-process is moved to standard input.
  2497. .TP
  2498. .B >&p
  2499. The output to the co-process is moved to standard output.
  2500. .PP
  2501. If one of the above is preceded by a digit,
  2502. then the
  2503. file descriptor number referred to is that specified
  2504. by the digit
  2505. (instead of the default 0 or 1).
  2506. For example:
  2507. .RS
  2508. .PP
  2509. \&.\|.\|. \|2>&1
  2510. .RE
  2511. .PP
  2512. means file descriptor 2 is to be opened
  2513. for writing as a duplicate
  2514. of file descriptor 1.
  2515. .PP
  2516. The order in which redirections are specified is significant.
  2517. The shell evaluates each redirection in terms of the
  2518. .RI ( "file descriptor" ", " file )
  2519. association at the time of evaluation.
  2520. For example:
  2521. .RS
  2522. .PP
  2523. \&.\|.\|. \|1>\f2fname\^\fP 2>&1
  2524. .RE
  2525. .PP
  2526. first associates file descriptor 1 with file
  2527. .IR fname\^ .
  2528. It then associates file descriptor 2 with the file associated with file
  2529. descriptor 1 (i.e.
  2530. .IR fname\^ ).
  2531. If the order of redirections were reversed, file descriptor 2 would be associated
  2532. with the terminal (assuming file descriptor 1 had been) and then file descriptor
  2533. 1 would be associated with file
  2534. .IR fname\^ .
  2535. .PP
  2536. If a command is followed by
  2537. .B &
  2538. and job control is not active,
  2539. then the default standard input
  2540. for the command
  2541. is the empty file
  2542. .BR /dev/null .
  2543. Otherwise, the environment for the execution of a command contains the
  2544. file descriptors of the invoking shell as modified by
  2545. input/output specifications.
  2546. .SS Environment.
  2547. The
  2548. .I environment\^
  2549. (see
  2550. .IR environ (7))
  2551. is a list of name-value pairs that is passed to
  2552. an executed program in the same way as a normal argument list.
  2553. The names must be
  2554. .I identifiers\^
  2555. and the values are character strings.
  2556. The shell interacts with the environment in several ways.
  2557. On invocation, the shell scans the environment
  2558. and creates a
  2559. variable
  2560. for each name found,
  2561. giving it the corresponding value and attributes and marking it
  2562. .IR export .
  2563. Executed commands inherit the environment.
  2564. If the user modifies the values of these
  2565. variables
  2566. or creates new ones,
  2567. using the
  2568. .B export
  2569. or
  2570. .B typeset \-x
  2571. commands they become part of the
  2572. environment.
  2573. The environment seen by any executed command is thus composed
  2574. of any name-value pairs originally inherited by the shell,
  2575. whose values may be modified by the current shell,
  2576. plus any additions
  2577. which must be noted in
  2578. .B export
  2579. or
  2580. .B typeset \-x
  2581. commands.
  2582. .PP
  2583. The environment for any
  2584. .I simple-command\^
  2585. or function
  2586. may be augmented by prefixing it with one or more variable assignments.
  2587. A variable assignment argument is a word of the form
  2588. .IR identifier=value .
  2589. Thus:
  2590. .RS
  2591. .PP
  2592. \s-1TERM\s+1=450 \|cmd \|args and
  2593. .br
  2594. (export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)
  2595. .RE
  2596. .PP
  2597. are equivalent (as far as the above execution of
  2598. .I cmd\^
  2599. is concerned except for special built-in commands listed below \-
  2600. those that are
  2601. preceded with a dagger).
  2602. .PP
  2603. If the obsolete
  2604. .B \-k
  2605. option is set,
  2606. .I all\^
  2607. variable assignment arguments are placed in the environment,
  2608. even if they occur after the command name.
  2609. The following
  2610. first prints
  2611. .B "a=b c"
  2612. and then
  2613. .BR c :
  2614. .PP
  2615. .RS
  2616. .nf
  2617. echo \|a=b \|c
  2618. set \|\-k
  2619. echo \|a=b \|c
  2620. .fi
  2621. .RE
  2622. This feature is intended for use with scripts written
  2623. for early versions of the shell and its use in new scripts
  2624. is strongly discouraged.
  2625. It is likely to disappear someday.
  2626. .SS Functions.
  2627. .PP
  2628. For historical reasons, there are two
  2629. ways to define functions,
  2630. the
  2631. .IB name (\^)
  2632. syntax and
  2633. the
  2634. .B function
  2635. .I name\^
  2636. syntax, described in the
  2637. .I Commands
  2638. section above.
  2639. Shell functions are read in and stored internally.
  2640. Alias names are resolved when the function is read.
  2641. Functions are executed like commands with the arguments
  2642. passed as positional parameters.
  2643. (See
  2644. .I Execution
  2645. below.)
  2646. .PP
  2647. Functions defined by the
  2648. .B function
  2649. .I name
  2650. syntax and called by name execute in the same process as the caller and
  2651. share all files
  2652. and present working directory with the
  2653. caller.
  2654. Traps caught by the caller are reset to their default action
  2655. inside the function.
  2656. A trap condition that is not caught or ignored by the
  2657. function causes the function to terminate and the condition
  2658. to be passed on to the caller.
  2659. A trap on
  2660. .SM
  2661. .B EXIT
  2662. set inside a function
  2663. is executed after the function completes in the environment
  2664. of the caller.
  2665. Ordinarily,
  2666. variables are shared between the calling program
  2667. and the function.
  2668. However,
  2669. the
  2670. .B typeset
  2671. special built-in command used within a function
  2672. defines local variables whose scope includes
  2673. the current function and
  2674. all functions it calls.
  2675. Errors within functions return control to the caller.
  2676. .PP
  2677. Functions defined with the
  2678. .IB name (\^)
  2679. syntax and functions defined with the
  2680. .B function
  2681. .I name
  2682. syntax that are invoked with the \f3\s+2.\s-2\fP
  2683. special built-in
  2684. are executed in the caller's
  2685. environment and share all variables
  2686. and traps with the caller.
  2687. Errors within these function executions cause the script that contains
  2688. them to abort.
  2689. .PP
  2690. The special built-in command
  2691. .B return
  2692. is used to return
  2693. from function calls.
  2694. .PP
  2695. Function names
  2696. can be listed with the
  2697. .B \-f
  2698. or
  2699. .B +f
  2700. option of the
  2701. .B typeset
  2702. special built-in command.
  2703. The text of functions, when available, will also
  2704. be listed with
  2705. .BR \-f .
  2706. Functions can be undefined with the
  2707. .B \-f
  2708. option of the
  2709. .B unset
  2710. special built-in command.
  2711. .PP
  2712. Ordinarily, functions are unset when the shell executes a shell script.
  2713. Functions that need to be defined across separate
  2714. invocations of the shell should
  2715. be placed in a directory and the
  2716. .B
  2717. .SM
  2718. FPATH
  2719. variable should contains the name of this directory.
  2720. They may also
  2721. be specified in the
  2722. .B
  2723. .SM
  2724. ENV
  2725. file.
  2726. .SS Jobs.
  2727. .PP
  2728. If the
  2729. .B monitor
  2730. option of the
  2731. .B set
  2732. command is turned on,
  2733. an interactive shell associates a \fIjob\fR with each pipeline.
  2734. It keeps
  2735. a table of current jobs, printed by the
  2736. .B jobs
  2737. command, and assigns them small integer numbers.
  2738. When a job is started asynchronously with
  2739. .BR & ,
  2740. the shell prints a line which looks
  2741. like:
  2742. .PP
  2743. .DT
  2744. [1] 1234
  2745. .PP
  2746. indicating that the job which was started asynchronously was job number
  2747. 1 and had one (top-level) process, whose process id was 1234.
  2748. .PP
  2749. This paragraph and the next require features that are
  2750. not in all versions of UNIX and may not apply.
  2751. If you are running a job and wish to do something else you may hit the key
  2752. \fB^Z\fR (control-Z) which sends a STOP signal to the current job.
  2753. The shell will then normally indicate that the job has been `Stopped',
  2754. and print another prompt.
  2755. You can then manipulate the state of this job,
  2756. putting it in the background with the
  2757. .B bg
  2758. command, or run some other
  2759. commands and then eventually bring the job back into the foreground with
  2760. the foreground command
  2761. .BR fg .
  2762. A \fB^Z\fR takes effect immediately and
  2763. is like an interrupt in that pending output and unread input are discarded
  2764. when it is typed.
  2765. .PP
  2766. A job being run in the background will stop if it tries to read
  2767. from the terminal.
  2768. Background jobs are normally allowed to produce output,
  2769. but this can be disabled by giving the command ``stty tostop''.
  2770. If you set this
  2771. tty option, then background jobs will stop when they try to produce
  2772. output like they do when they try to read input.
  2773. .PP
  2774. There are several ways to refer to jobs in the shell.
  2775. A job can be referred to by the process id of any process of the job
  2776. or by one of the following:
  2777. .PD 0
  2778. .TP
  2779. .BI % number
  2780. The job with the given number.
  2781. .TP
  2782. .BI % string
  2783. Any job whose command line begins with
  2784. .IR string .
  2785. .TP
  2786. .BI %? string
  2787. Any job whose command line contains
  2788. .IR string .
  2789. .TP
  2790. .BI %%
  2791. Current job.
  2792. .TP
  2793. .BI %+
  2794. Equivalent to
  2795. .BR %% .
  2796. .TP
  2797. .BI %\-
  2798. Previous job.
  2799. .PD
  2800. .PP
  2801. The shell learns immediately whenever a process changes state.
  2802. It normally informs you whenever a job becomes blocked so that
  2803. no further progress is possible, but only just before it prints
  2804. a prompt.
  2805. This is done so that it does not otherwise disturb your work.
  2806. The
  2807. .B notify
  2808. option causes
  2809. the shell to print these job change messages
  2810. as soon as they occur.
  2811. .PP
  2812. When the
  2813. .B monitor
  2814. option is on, each background job that completes
  2815. triggers any trap set for
  2816. .BR CHLD .
  2817. .PP
  2818. When you try to leave the shell while jobs are running or stopped, you will
  2819. be warned that `You have stopped(running) jobs.'
  2820. You may use the
  2821. .B jobs
  2822. command to see what they are.
  2823. If you immediately try to
  2824. exit again, the shell will not warn you a second time, and the stopped
  2825. jobs will be terminated.
  2826. When a login shell receives a HUP signal, it sends
  2827. a HUP signal to each job that has not been disowned witha the
  2828. .B disown
  2829. built-in command described below.
  2830. .SS Signals.
  2831. The \s-1INT\s+1 and \s-1QUIT\s+1 signals for an invoked
  2832. command are ignored if the command is followed by
  2833. .B &
  2834. and the
  2835. .B monitor
  2836. option is not active.
  2837. Otherwise, signals have the values
  2838. inherited by the shell from its parent
  2839. (but see also
  2840. the
  2841. .B trap
  2842. built-in command below).
  2843. .SS Execution.
  2844. Each time a command is read, the above substitutions
  2845. are carried out.
  2846. If the command name matches one
  2847. of the
  2848. .I "Special built-in Commands\^"
  2849. listed below,
  2850. it is executed within the
  2851. current shell process.
  2852. Next, the command name is checked to see if
  2853. it matches a user defined function.
  2854. If it does,
  2855. the positional parameters are saved
  2856. and then reset to the arguments of the
  2857. .I function\^
  2858. call.
  2859. When the
  2860. .I function\^
  2861. completes or issues a
  2862. .BR return ,
  2863. the positional parameter list is restored.
  2864. For functions defined with the
  2865. .B function
  2866. .I name\^
  2867. syntax,
  2868. any trap set on
  2869. .SM
  2870. .B EXIT
  2871. within the function is executed.
  2872. The value of a
  2873. .I function\^
  2874. is the value of the last command executed.
  2875. A function is also executed in the
  2876. current shell process.
  2877. If a command name is not a
  2878. .I "special built-in command\^"
  2879. or a user defined
  2880. .IR function ,
  2881. but it is one of the built-in commands listed below
  2882. it is executed in the current shell process.
  2883. .PP
  2884. The shell variable
  2885. .B
  2886. .SM PATH
  2887. defines the search path for
  2888. the directory containing the command.
  2889. Alternative directory names are separated by
  2890. a colon
  2891. .RB ( : ).
  2892. The default path is
  2893. .B /bin:/usr/bin:
  2894. (specifying
  2895. .BR /bin ,
  2896. .BR /usr/bin ,
  2897. and the current directory
  2898. in that order).
  2899. The current directory can be specified by
  2900. two or more adjacent colons, or by a colon
  2901. at the beginning or end of the path list.
  2902. If the command name contains a \f3/\fP then the search path
  2903. is not used.
  2904. Otherwise, each directory in the path is
  2905. searched for an executable file that is not a directory.
  2906. If the shell
  2907. determines that there is a built-in version
  2908. of a command corresponding to a given pathname,
  2909. this built-in is invoked in the current process.
  2910. A process is created and
  2911. an attempt is made to execute the command via
  2912. .IR exec (2).
  2913. If the file has execute permission but is not an
  2914. .B a.out
  2915. file,
  2916. it is assumed to be a file containing shell commands.
  2917. A separate shell is spawned to read it.
  2918. All non-exported variables are removed in this case.
  2919. If the shell command
  2920. file doesn't have read permission,
  2921. or if the
  2922. .I setuid
  2923. and/or
  2924. .I setgid
  2925. bits are set on the file,
  2926. then the shell executes an agent whose job it is to
  2927. set up the permissions and execute the shell with the
  2928. shell command file passed down as an open file.
  2929. A parenthesized command is executed in
  2930. a sub-shell without removing non-exported variables.
  2931. .SS Command Re-entry.
  2932. The text of the last
  2933. .B
  2934. .SM
  2935. HISTSIZE
  2936. (default 128)
  2937. commands entered from a terminal device
  2938. is saved in a
  2939. .I history
  2940. file.
  2941. The file
  2942. .B \s-1$HOME\s+1/.sh_history
  2943. is used if the
  2944. .B
  2945. .SM
  2946. HISTFILE
  2947. variable is not set
  2948. or if the file it names is not writable.
  2949. A shell can access the commands of
  2950. all
  2951. .I interactive
  2952. shells which use the same named
  2953. .SM
  2954. .BR HISTFILE .
  2955. The built-in command
  2956. .B hist\^
  2957. is used to list or
  2958. edit a portion of this file.
  2959. The portion of the file to be edited or listed can be selected by
  2960. number or by giving the first character or
  2961. characters of the command.
  2962. A single command or range of commands can be specified.
  2963. If you do not specify an editor program as
  2964. an argument to
  2965. .B hist\^
  2966. then the value of the variable
  2967. .SM
  2968. .B HISTEDIT
  2969. is used.
  2970. If
  2971. .SM
  2972. .B HISTEDIT
  2973. is unset, the obsolete variable
  2974. .SM
  2975. .B FCEDIT
  2976. is used.
  2977. If
  2978. .SM
  2979. .B FCEDIT
  2980. is not defined then
  2981. .B /bin/ed
  2982. is used.
  2983. The edited command(s) is printed and re-executed upon
  2984. leaving the editor unless you quit without writing.
  2985. The
  2986. .B \-s
  2987. option
  2988. (
  2989. an in obsolete versions, the editor name
  2990. .B \-
  2991. )
  2992. is used to skip the editing phase and
  2993. to re-execute the command.
  2994. In this case a substitution parameter of the form
  2995. \f2old\fP\f3=\fP\f2new\fP
  2996. can be used to modify the command before execution.
  2997. For example, with the preset alias
  2998. .BR r ,
  2999. which is aliased to
  3000. .BR "\(fmhist \-s\(fm" ,
  3001. typing
  3002. `\f3r bad=good c\fP'
  3003. will re-execute the most recent command which starts with the letter
  3004. .BR c ,
  3005. replacing the first occurrence of the string
  3006. .B bad
  3007. with the string
  3008. .BR good .
  3009. .SS In-line Editing Options
  3010. Normally, each command line entered from a terminal device is simply
  3011. typed followed by a \f3new-line\fP (`RETURN' or `LINE\ FEED').
  3012. If either the
  3013. .BR emacs ,
  3014. .BR gmacs ,
  3015. or
  3016. .B vi
  3017. option is active, the user can edit the command line.
  3018. To be in either of these edit modes
  3019. .B set
  3020. the corresponding
  3021. option.
  3022. An editing option is automatically selected each time the
  3023. .SM
  3024. .B VISUAL
  3025. or
  3026. .SM
  3027. .B EDITOR
  3028. variable is assigned a value ending in either of these
  3029. option names.
  3030. .PP
  3031. The editing features require that the user's terminal
  3032. accept `RETURN' as carriage return without line feed
  3033. and that a space (`\ ') must overwrite the current character on
  3034. the screen.
  3035. .PP
  3036. The editing modes implement a concept where the user is looking through a
  3037. window at the current line.
  3038. The window width is the value of
  3039. .SM
  3040. .B COLUMNS
  3041. if it is defined, otherwise 80.
  3042. If the window width is too small to display the prompt and leave
  3043. at least 8 columns to enter input, the prompt is truncated from the
  3044. left.
  3045. If the line is longer than the window width minus two, a mark is
  3046. displayed at the end of the window to notify the user.
  3047. As the cursor moves and reaches the window boundaries the window will be
  3048. centered about the cursor.
  3049. The mark is a
  3050. .BR > " (<" ,
  3051. .BR * )
  3052. if the line extends on the
  3053. right (left, both) side(s) of the window.
  3054. .PP
  3055. The search commands in each edit mode provide access to the history file.
  3056. Only strings are matched, not patterns, although a leading
  3057. .B ^
  3058. in the string restricts the match
  3059. to begin at the first character in the line.
  3060. .PP
  3061. Each of the edit modes has an operation to list the files
  3062. or commands that match a partially entered word.
  3063. When applied to the first word on the line,
  3064. or the first word after a
  3065. .BR ; ,
  3066. .BR \(bv ,
  3067. .BR & ,
  3068. or
  3069. .BR ( ,
  3070. and the word does not begin with
  3071. .B \(ap
  3072. or contain a
  3073. .BR / ,
  3074. the list of aliases, functions, and executable commands
  3075. defined by the
  3076. .B
  3077. .SM PATH
  3078. variable that could match the partial word is displayed.
  3079. Otherwise, the list of files that match the given
  3080. word is displayed.
  3081. If the partially entered word does not contain any
  3082. file expansion characters, a
  3083. .B *
  3084. is appended before generating these lists.
  3085. After displaying the generated list, the input line
  3086. is redrawn.
  3087. These operations are called command name listing and file name listing,
  3088. respectively.
  3089. There are additional operations, referred to as command name
  3090. completion and file name completion, which compute the list
  3091. of matching commands or files, but instead of printing the list,
  3092. replace
  3093. the current word with a complete or partial match.
  3094. For file name completion,
  3095. if the match is unique, a
  3096. .B /
  3097. is appended if the file is a directory and a space is
  3098. appended if the file is not a directory.
  3099. Otherwise, the longest common prefix for all the matching
  3100. files replaces the word.
  3101. For command name completion, only the portion of the file names
  3102. after the last
  3103. .B /
  3104. are used to find the longest command prefix.
  3105. If only a single name matches this prefix, then the
  3106. word is replaced with the command name followed by a space.
  3107. .SS Key Bindings.
  3108. The
  3109. .B
  3110. .SM KEYBD
  3111. trap can be used to intercept keys as they are typed
  3112. and change the characters that are actually seen by
  3113. the shell.
  3114. This trap is executed after each character
  3115. ( or sequence of characters when the first character is
  3116. .B ESC
  3117. ) is entered while reading from a terminal.
  3118. The variable
  3119. .B .sh.edchar
  3120. contains the character or character sequence which
  3121. generated the trap.
  3122. Changing the value of
  3123. .B .sh.edchar
  3124. in the trap action causes the shell to behave as if the
  3125. new value were entered from the keyboard rather than
  3126. the original value.
  3127. .PP
  3128. The variable
  3129. .B .sh.edcol
  3130. is set to the input column number of the cursor at the time
  3131. of the input.
  3132. The variable
  3133. .B .sh.edmode
  3134. is set to
  3135. .B ESC
  3136. when in vi insert mode (see below) and is null otherwise.
  3137. By prepending
  3138. .B ${.sh.editmode}
  3139. to a value assigned to
  3140. .B .sh.edchar
  3141. it will cause the shell
  3142. to change to control mode if it is not already in this mode.
  3143. .PP
  3144. This trap is not invoked for characters entered as arguments to
  3145. editing directives, or while reading input for a character search.
  3146. .SS Emacs Editing Mode.
  3147. This mode is entered by enabling either the
  3148. .I emacs
  3149. or
  3150. .I gmacs
  3151. option.
  3152. The only difference between these two modes is the way
  3153. they handle
  3154. .BR ^T .
  3155. To edit, the user
  3156. moves the cursor to the point needing correction and
  3157. then inserts or deletes characters or words as needed.
  3158. All the editing commands are control characters or escape
  3159. sequences.
  3160. The notation for control characters is caret (
  3161. .B ^
  3162. ) followed
  3163. by the character.
  3164. For example,
  3165. .B ^F
  3166. is the notation for control
  3167. .BR F .
  3168. This is entered by depressing `f' while holding down the
  3169. `CTRL' (control) key.
  3170. The `SHIFT' key is
  3171. .I not
  3172. depressed.
  3173. (The notation
  3174. .B ^?
  3175. indicates the DEL (delete) key.)
  3176. .PP
  3177. The notation for escape sequences is
  3178. .B M-
  3179. followed by a
  3180. character.
  3181. For example,
  3182. .B M-f
  3183. (pronounced Meta f)
  3184. is entered by depressing ESC
  3185. (ascii
  3186. .BR 033 )
  3187. followed by `f'.
  3188. .RB ( M-F
  3189. would be the notation for ESC followed by `SHIFT' (capital) `F'.)
  3190. .PP
  3191. All edit commands
  3192. operate from any place on the line
  3193. (not just at the beginning).
  3194. Neither the "RETURN" nor the "LINE FEED" key is
  3195. entered after edit commands except when noted.
  3196. .PP
  3197. .PD 0
  3198. .TP 10
  3199. .BI ^F
  3200. Move cursor forward (right) one character.
  3201. .PP
  3202. .TP 10
  3203. .BI M-f
  3204. Move cursor forward one word.
  3205. (The
  3206. .B emacs
  3207. editor's idea of a word is a string of characters
  3208. consisting of only letters, digits and underscores.)
  3209. .PP
  3210. .TP 10
  3211. .BI ^B
  3212. Move cursor backward (left) one character.
  3213. .PP
  3214. .TP 10
  3215. .BI M-b
  3216. Move cursor backward one word.
  3217. .PP
  3218. .TP 10
  3219. .BI ^A
  3220. Move cursor to start of line.
  3221. .PP
  3222. .TP 10
  3223. .BI ^E
  3224. Move cursor to end of line.
  3225. .PP
  3226. .TP 10
  3227. .BI ^] char
  3228. Move cursor forward to character
  3229. .I char
  3230. on current line.
  3231. .PP
  3232. .TP 10
  3233. .BI M-^] char
  3234. Move cursor backward to character
  3235. .I char
  3236. on current line.
  3237. .PP
  3238. .TP 10
  3239. .BI ^X^X
  3240. Interchange the cursor and mark.
  3241. .PP
  3242. .TP 10
  3243. .I erase
  3244. (User defined erase character as defined
  3245. by the
  3246. .IR stty (1)
  3247. command, usually
  3248. .B ^H
  3249. or
  3250. .BR # .)
  3251. Delete previous character.
  3252. .PP
  3253. .TP 10
  3254. .BI ^D
  3255. Delete current character.
  3256. .PP
  3257. .TP 10
  3258. .BI M-d
  3259. Delete current word.
  3260. .PP
  3261. .TP 10
  3262. .BI M-^H
  3263. (Meta-backspace) Delete previous word.
  3264. .PP
  3265. .TP 10
  3266. .BI M-h
  3267. Delete previous word.
  3268. .PP
  3269. .TP 10
  3270. .BI M-^?
  3271. (Meta-DEL) Delete previous word (if your interrupt character is
  3272. .B ^?
  3273. (DEL, the default) then this command will not work).
  3274. .PP
  3275. .TP 10
  3276. .BI ^T
  3277. Transpose current character with next character in
  3278. .I emacs
  3279. mode.
  3280. Transpose two previous characters in
  3281. .I gmacs
  3282. mode.
  3283. .PP
  3284. .TP 10
  3285. .BI ^C
  3286. Capitalize current character.
  3287. .PP
  3288. .TP 10
  3289. .BI M-c
  3290. Capitalize current word.
  3291. .PP
  3292. .TP 10
  3293. .BI M-l
  3294. Change the current word to lower case.
  3295. .PP
  3296. .TP 10
  3297. .BI ^K
  3298. Delete from the cursor to the end of the line.
  3299. If preceded by a numerical parameter whose value is less than the
  3300. current cursor position, then delete from given position
  3301. up to the cursor.
  3302. If preceded by a numerical parameter whose value is greater than the
  3303. current cursor position, then delete from cursor up to
  3304. given cursor position.
  3305. .PP
  3306. .TP 10
  3307. .BI ^W
  3308. Kill from the cursor to the mark.
  3309. .PP
  3310. .TP 10
  3311. .BI M-p
  3312. Push the region from the cursor to the mark on the stack.
  3313. .PP
  3314. .TP 10
  3315. .I kill
  3316. (User defined kill character as defined
  3317. by the stty command, usually
  3318. .B ^G
  3319. or
  3320. .BR @ .)
  3321. Kill the entire current line.
  3322. If two
  3323. .I kill
  3324. characters are entered in succession, all
  3325. kill characters from then on cause a line feed
  3326. (useful when using paper terminals).
  3327. .PP
  3328. .TP 10
  3329. .BI ^Y
  3330. Restore last item removed from line. (Yank item back to the line.)
  3331. .PP
  3332. .TP 10
  3333. .BI ^L
  3334. Line feed and print current line.
  3335. .PP
  3336. .TP 10
  3337. .BI ^@
  3338. (Null character) Set mark.
  3339. .PP
  3340. .TP 10
  3341. .BI M- space
  3342. (Meta space) Set mark.
  3343. .PP
  3344. .TP 10
  3345. .BI ^J
  3346. (New\ line) Execute the current line.
  3347. .PP
  3348. .TP 10
  3349. .BI ^M
  3350. (Return) Execute the current line.
  3351. .PP
  3352. .TP 10
  3353. .I eof
  3354. End-of-file character,
  3355. normally
  3356. .BR ^D ,
  3357. is processed as an End-of-file only
  3358. if the current line is null.
  3359. .PP
  3360. .TP 10
  3361. .BI ^P
  3362. Fetch previous command.
  3363. Each time
  3364. .B ^P
  3365. is entered
  3366. the previous command back in time is accessed.
  3367. Moves back one line when not on the first line of a multi-line command.
  3368. .PP
  3369. .TP 10
  3370. .BI M-<
  3371. Fetch the least recent (oldest) history line.
  3372. .PP
  3373. .TP 10
  3374. .BI M->
  3375. Fetch the most recent (youngest) history line.
  3376. .PP
  3377. .TP 10
  3378. .BI ^N
  3379. Fetch next command line.
  3380. Each time
  3381. .B ^N
  3382. is entered
  3383. the next command line forward in time is accessed.
  3384. .PP
  3385. .TP 10
  3386. .BI ^R string
  3387. Reverse search history for a previous command line containing
  3388. .IR string .
  3389. If a parameter of zero is given, the search is forward.
  3390. .I String
  3391. is terminated by a "RETURN" or "NEW\ LINE".
  3392. If string is preceded by a
  3393. .BR ^ ,
  3394. the matched line must begin with
  3395. .IR string .
  3396. If
  3397. .I string
  3398. is omitted,
  3399. then the next command line containing the most recent
  3400. .I string
  3401. is accessed.
  3402. In this case a parameter of zero
  3403. reverses the direction of the search.
  3404. .PP
  3405. .TP 10
  3406. .B ^O
  3407. Operate \- Execute the current line and fetch
  3408. the next line relative to current line from the
  3409. history file.
  3410. .PP
  3411. .TP 10
  3412. .BI M- digits
  3413. (Escape) Define numeric parameter, the digits
  3414. are taken as a parameter to the next command.
  3415. The commands that accept a parameter are
  3416. .BR ^F ,
  3417. .BR ^B ,
  3418. .IR erase ,
  3419. .BR ^C ,
  3420. .BR ^D ,
  3421. .BR ^K ,
  3422. .BR ^R ,
  3423. .BR ^P ,
  3424. .BR ^N ,
  3425. .BR ^] ,
  3426. .BR M-. ,
  3427. .BR M-^] ,
  3428. .BR M-_ ,
  3429. .BR M-b ,
  3430. .BR M-c ,
  3431. .BR M-d ,
  3432. .BR M-f ,
  3433. .BR M-h ,
  3434. .B M-l
  3435. and
  3436. .BR M-^H .
  3437. .PP
  3438. .TP 10
  3439. .BI M- letter
  3440. Soft-key \- Your alias list is searched for an
  3441. alias by the name
  3442. .BI _ letter
  3443. and if an alias of this name is defined, its
  3444. value will be inserted on the input queue.
  3445. The
  3446. .I letter
  3447. must not be one of the above meta-functions.
  3448. .PP
  3449. .TP 10
  3450. .BI M-[ letter
  3451. Soft-key \- Your alias list is searched for an
  3452. alias by the name
  3453. .BI _\&_ letter
  3454. and if an alias of this name is defined, its
  3455. value will be inserted on the input queue.
  3456. The can be used to program functions keys on many terminals.
  3457. .PP
  3458. .TP 10
  3459. .B M-.
  3460. The last word of the previous command is inserted
  3461. on the line.
  3462. If preceded by a numeric parameter, the value
  3463. of this parameter determines which word to insert rather than
  3464. the last word.
  3465. .PP
  3466. .TP 10
  3467. .B M-_
  3468. Same as
  3469. .BR M-. .
  3470. .PP
  3471. .TP 10
  3472. .B M-*
  3473. Attempt file name generation on the current word.
  3474. An asterisk is appended if the word doesn't match any file
  3475. or contain any special
  3476. pattern characters.
  3477. .PP
  3478. .TP 10
  3479. Command or file name completion as described above.
  3480. .PP
  3481. .TP 10
  3482. .B M-=
  3483. Command or file name listing as described above.
  3484. .PP
  3485. .TP 10
  3486. .BI ^U
  3487. Multiply parameter of next command by 4.
  3488. .PP
  3489. .TP 10
  3490. .BI \e
  3491. Escape next character.
  3492. Editing characters, the user's erase, kill and
  3493. interrupt (normally
  3494. .BR ^? )
  3495. characters
  3496. may be entered
  3497. in a command line or in a search string if preceded by a
  3498. .BR \e .
  3499. The
  3500. .B \e
  3501. removes the next character's
  3502. editing features (if any).
  3503. .PP
  3504. .TP 10
  3505. .BI ^V
  3506. Display version of the shell.
  3507. .PP
  3508. .TP 10
  3509. .BI M-\#
  3510. If the line does not begin with a
  3511. .BR \# ,
  3512. a
  3513. .B \#
  3514. is inserted
  3515. at the beginning of the line
  3516. and after each new-line,
  3517. and the line is entered.
  3518. This causes a comment to be inserted in the history file.
  3519. If the line begins with a
  3520. .BR \# ,
  3521. the
  3522. .B \#
  3523. is deleted and one
  3524. .B \#
  3525. after each new-line is also deleted.
  3526. .PD
  3527. .SS Vi Editing Mode.
  3528. There are two typing modes.
  3529. Initially, when you enter a command you are in the
  3530. .I input\^
  3531. mode.
  3532. To edit, the user enters
  3533. .I control\^
  3534. mode by typing ESC
  3535. .RB ( 033 )
  3536. and moves the cursor to the point needing correction and
  3537. then inserts or deletes characters or words as needed.
  3538. Most control commands accept an optional repeat
  3539. .I count
  3540. prior to the command.
  3541. .P
  3542. When in
  3543. .B vi
  3544. mode on most systems,
  3545. canonical processing is initially enabled and the
  3546. command will be echoed again if the speed is 1200 baud or greater and it
  3547. contains any control characters or less than one second has elapsed
  3548. since the prompt was printed.
  3549. The ESC character terminates canonical processing for the remainder of the command
  3550. and the user can then modify the command line.
  3551. This scheme has the advantages of canonical processing with the type-ahead
  3552. echoing of raw mode.
  3553. .P
  3554. If the option
  3555. .B viraw\^
  3556. is also set, the terminal will always have canonical processing
  3557. disabled.
  3558. This mode is implicit for systems that do not support two
  3559. alternate end of line delimiters,
  3560. and may be helpful for certain terminals.
  3561. .SS "\ \ \ \ \ Input Edit Commands"
  3562. .PP
  3563. .RS
  3564. By default the editor is in input mode.
  3565. .PD 0
  3566. .TP 10
  3567. .I erase
  3568. (User defined erase character as defined
  3569. by the stty command, usually
  3570. .B ^H
  3571. or
  3572. .BR # .)
  3573. Delete previous character.
  3574. .TP 10
  3575. .BI ^W
  3576. Delete the previous blank separated word.
  3577. One some systems the \f3viraw\fP option
  3578. may be required for this to work.
  3579. .TP 10
  3580. .I eof
  3581. As the first character of the line causes
  3582. the shell to terminate unless the \f3ignoreeof\fP
  3583. option is set.
  3584. Otherwise this character is ignored.
  3585. .TP 10
  3586. .BI ^V
  3587. Escape next character.
  3588. Editing characters and the user's erase or kill
  3589. characters may be entered
  3590. in a command line or in a search string if preceded by a
  3591. .BR ^V .
  3592. The
  3593. .B ^V
  3594. removes the next character's
  3595. editing features (if any).
  3596. One some systems the \f3viraw\fP option
  3597. may be required for this to work.
  3598. .TP 10
  3599. .BI \e
  3600. Escape the next
  3601. .I erase
  3602. or
  3603. .I kill
  3604. character.
  3605. .P
  3606. .RE
  3607. .SS "\ \ \ \ \ Motion Edit Commands"
  3608. .RS
  3609. These commands will move the cursor.
  3610. .TP 10
  3611. [\f2count\fP]\f3l\fP
  3612. Cursor forward (right) one character.
  3613. .TP 10
  3614. [\f2count\fP]\f3w\fP
  3615. Cursor forward one alpha-numeric word.
  3616. .TP 10
  3617. [\f2count\fP]\f3W\fP
  3618. Cursor to the beginning of the next word that follows a blank.
  3619. .TP 10
  3620. [\f2count\fP]\f3e\fP
  3621. Cursor to end of word.
  3622. .TP 10
  3623. [\f2count\fP]\f3E\fP
  3624. Cursor to end of the current blank delimited word.
  3625. .TP 10
  3626. [\f2count\fP]\f3h\fP
  3627. Cursor backward (left) one character.
  3628. .TP 10
  3629. [\f2count\fP]\f3b\fP
  3630. Cursor backward one word.
  3631. .TP 10
  3632. [\f2count\fP]\f3B\fP
  3633. Cursor to preceding blank separated word.
  3634. .TP 10
  3635. [\f2count\fP]\f3\(bv\fP
  3636. Cursor to column
  3637. .IR count .
  3638. .TP 10
  3639. [\f2count\fP]\f3f\fP\f2c\fP
  3640. Find the next character \fIc\fP in the current line.
  3641. .TP 10
  3642. [\f2count\fP]\f3F\fP\f2c\fP
  3643. Find the previous character \fIc\fP in the current line.
  3644. .TP 10
  3645. [\f2count\fP]\f3t\fP\f2c\fP
  3646. Equivalent to
  3647. .B f
  3648. followed by
  3649. .BR h .
  3650. .TP 10
  3651. [\f2count\fP]\f3T\fP\f2c\fP
  3652. Equivalent to
  3653. .B F
  3654. followed by
  3655. .BR l .
  3656. .TP 10
  3657. [\f2count\fP]\f3;\fP
  3658. Repeats
  3659. .I count
  3660. times,
  3661. the last single character find command,
  3662. .BR f ,
  3663. .BR F ,
  3664. .BR t ,
  3665. or
  3666. .BR T .
  3667. .TP 10
  3668. [\f2count\fP]\f3,\fP
  3669. Reverses the last single character find command
  3670. .I count
  3671. times.
  3672. .TP 10
  3673. .B 0
  3674. Cursor to start of line.
  3675. .TP 10
  3676. .B ^
  3677. Cursor to first non-blank character in line.
  3678. .TP 10
  3679. .B $
  3680. Cursor to end of line.
  3681. .TP 10
  3682. .B %
  3683. Moves to balancing
  3684. .BR ( ,
  3685. .BR ) ,
  3686. .BR { ,
  3687. .BR } ,
  3688. .BR [ ,
  3689. or
  3690. .BR ] .
  3691. If cursor is not on one of the above characters,
  3692. the remainder of the line is searched for the first
  3693. occurrence of one of the above characters first.
  3694. .RE
  3695. .SS "\ \ \ \ \ Search Edit Commands"
  3696. .RS
  3697. These commands access your command history.
  3698. .TP 10
  3699. [\f2count\fP]\f3k\fP
  3700. Fetch previous command.
  3701. Each time
  3702. .B k
  3703. is entered
  3704. the previous command back in time is accessed.
  3705. .TP 10
  3706. [\f2count\fP]\f3\-\fP
  3707. Equivalent to
  3708. .BR k .
  3709. .TP 10
  3710. [\f2count\fP]\f3j\fP
  3711. Fetch next command.
  3712. Each time
  3713. .B j
  3714. is entered
  3715. the next command forward in time is accessed.
  3716. .TP 10
  3717. [\f2count\fP]\f3+\fP
  3718. Equivalent to
  3719. .BR j .
  3720. .TP 10
  3721. [\f2count\fP]\f3G\fP
  3722. The command number
  3723. .I count
  3724. is fetched.
  3725. The default is the least recent history command.
  3726. .TP 10
  3727. .BI / string
  3728. Search backward through history for a previous command containing
  3729. .IR string .
  3730. .I String
  3731. is terminated by a "RETURN" or "NEW\ LINE".
  3732. If string is preceded by a
  3733. .BR ^ ,
  3734. the matched line must begin with
  3735. .IR string .
  3736. If \fIstring\fP is null the previous string will be used.
  3737. .TP 10
  3738. .BI ? string
  3739. Same as
  3740. .B /
  3741. except that search will be in the forward direction.
  3742. .TP 10
  3743. .B n
  3744. Search for next match of the last pattern to
  3745. .B /
  3746. or
  3747. .B ?
  3748. commands.
  3749. .TP 10
  3750. .B N
  3751. Search for next match of the last pattern to
  3752. .B /
  3753. or
  3754. .BR ? ,
  3755. but in reverse direction.
  3756. .RE
  3757. .SS "\ \ \ \ \ Text Modification Edit Commands"
  3758. .RS
  3759. These commands will modify the line.
  3760. .TP 10
  3761. .B a
  3762. Enter input mode and enter text after the current character.
  3763. .TP 10
  3764. .B A
  3765. Append text to the end of the line.
  3766. Equivalent to
  3767. .BR $a .
  3768. .TP 10
  3769. [\f2count\fP]\f3c\fP\f2motion\fP
  3770. .TP 10
  3771. \f3c\fP[\f2count\fP]\f2motion\fP
  3772. Delete current character through the character that
  3773. .I motion
  3774. would move the cursor to and enter input mode.
  3775. If \fImotion\fP is
  3776. .BR c ,
  3777. the entire line will be deleted and
  3778. input mode entered.
  3779. .TP 10
  3780. .B C
  3781. Delete the current character through the end of line and enter input mode.
  3782. Equivalent to
  3783. .BR c$ .
  3784. .TP 10
  3785. .B S
  3786. Equivalent to
  3787. .BR cc .
  3788. .TP 10
  3789. .B D
  3790. Delete the current character through the end of line.
  3791. Equivalent to
  3792. .BR d$ .
  3793. .TP 10
  3794. [\f2count\fP]\f3d\fP\f2motion\fP
  3795. .TP 10
  3796. \f3d\fP[\f2count\fP]\f2motion\fP
  3797. Delete current character through the character that
  3798. .I motion
  3799. would move to.
  3800. If \fImotion\fP is
  3801. .B d ,
  3802. the entire line will be deleted.
  3803. .TP 10
  3804. .B i
  3805. Enter input mode and insert text before the current character.
  3806. .TP 10
  3807. .B I
  3808. Insert text before the beginning of the line.
  3809. Equivalent to
  3810. .BR 0i .
  3811. .TP 10
  3812. [\f2count\fP]\f3P\fP
  3813. Place the previous text modification before the cursor.
  3814. .TP 10
  3815. [\f2count\fP]\f3p\fP
  3816. Place the previous text modification after the cursor.
  3817. .TP 10
  3818. .B R
  3819. Enter input mode and
  3820. replace characters on the screen with characters you type overlay fashion.
  3821. .TP 10
  3822. [\f2count\fP]\f3r\fP\f2c\fP
  3823. Replace the
  3824. .I count
  3825. character(s) starting at the current cursor position with
  3826. .IR c ,
  3827. and advance the cursor.
  3828. .TP 10
  3829. [\f2count\fP]\f3x\fP
  3830. Delete current character.
  3831. .TP 10
  3832. [\f2count\fP]\f3X\fP
  3833. Delete preceding character.
  3834. .TP 10
  3835. [\f2count\fP]\f3.\fP
  3836. Repeat the previous text modification command.
  3837. .TP 10
  3838. [\f2count\fP]\f3\(ap\fP
  3839. Invert the case of the
  3840. .I count
  3841. character(s) starting at the current cursor position and advance the cursor.
  3842. .TP 10
  3843. [\f2count\fP]\f3_\fP
  3844. Causes the
  3845. .I count\^
  3846. word of the previous command to be appended and
  3847. input mode entered.
  3848. The last word is used
  3849. if
  3850. .I count\^
  3851. is omitted.
  3852. .TP 10
  3853. .B *
  3854. Causes an
  3855. .B *
  3856. to be appended to the current word and file name generation attempted.
  3857. If no match is found,
  3858. it rings the bell.
  3859. Otherwise, the word is replaced
  3860. by the matching pattern and input mode is entered.
  3861. .TP 10
  3862. .B \e
  3863. Command or file name completion as described above.
  3864. .RE
  3865. .SS "\ \ \ \ \ Other Edit Commands"
  3866. .RS
  3867. Miscellaneous commands.
  3868. .TP 10
  3869. [\f2count\fP]\f3y\fP\f2motion\fP
  3870. .TP 10
  3871. \f3y\fP[\f2count\fP]\f2motion\fP
  3872. Yank current character through character that
  3873. .I motion
  3874. would move the cursor to and puts them into the delete buffer.
  3875. The text and cursor are unchanged.
  3876. .TP 10
  3877. .B Y
  3878. Yanks from current position to end of line.
  3879. Equivalent to
  3880. .BR y$ .
  3881. .TP 10
  3882. .B u
  3883. Undo the last text modifying command.
  3884. .TP 10
  3885. .B U
  3886. Undo all the text modifying commands performed on the line.
  3887. .TP 10
  3888. [\f2count\fP]\f3v\fP
  3889. Returns the command
  3890. .BI "hist \-e ${\s-1VISUAL\s+1:\-${\s-1EDITOR\s+1:\-vi}}" " count"
  3891. in the input buffer.
  3892. If
  3893. .I count\^
  3894. is omitted, then the current line is used.
  3895. .TP 10
  3896. .BI ^L
  3897. Line feed and print current line.
  3898. Has effect only in control mode.
  3899. .TP 10
  3900. .BI ^J
  3901. (New\ line) Execute the current line, regardless of mode.
  3902. .TP 10
  3903. .BI ^M
  3904. (Return) Execute the current line, regardless of mode.
  3905. .TP 10
  3906. .B \#
  3907. If the first character of the command is a
  3908. .BR \# ,
  3909. then this command deletes this
  3910. .B \#
  3911. and each
  3912. .B \#
  3913. that follows a newline.
  3914. Otherwise,
  3915. sends the line after
  3916. inserting a
  3917. .B \#
  3918. in front of each line in the command.
  3919. Useful for causing the current line to be
  3920. inserted in the history as a comment and
  3921. uncommenting previously commented commands
  3922. in the history file.
  3923. .TP 10
  3924. .B =
  3925. Command or file name listing as described above.
  3926. .TP 10
  3927. .BI @ letter
  3928. Your alias list is searched for an
  3929. alias by the name
  3930. .BI _ letter
  3931. and if an alias of this name is defined, its
  3932. value will be inserted on the input queue for processing.
  3933. .RE
  3934. .PD
  3935. .SS Built-in Commands.
  3936. The following simple-commands are executed in the shell process.
  3937. Input/Output redirection is permitted.
  3938. Unless otherwise indicated, the output is written on file descriptor 1
  3939. and the exit status, when there is no syntax error, is zero.
  3940. Except for
  3941. .BR : ,
  3942. .BR true ,
  3943. .BR false ,
  3944. .BR echo ,
  3945. .BR command ,
  3946. .BR newgrp ,
  3947. and
  3948. .BR login ,
  3949. all built-in commands accept
  3950. .B \-\-
  3951. to indicate end of options.
  3952. They also interpret the option
  3953. .B \-?
  3954. as a help request and print a
  3955. .I usage\^
  3956. message
  3957. on standard error.
  3958. Commands that are preceded by one or two \(dg
  3959. are special built-in commands and
  3960. are treated specially in the following ways:
  3961. .PD 0
  3962. .TP
  3963. 1.
  3964. Variable assignment lists preceding the command
  3965. remain in effect when the command completes.
  3966. .TP
  3967. 2.
  3968. I/O redirections are processed after variable assignments.
  3969. .TP
  3970. 3.
  3971. Errors
  3972. cause a script
  3973. that contains them to abort.
  3974. .TP
  3975. 4.
  3976. They are not valid function names.
  3977. .TP
  3978. 5.
  3979. Words,
  3980. following a command preceded by \(dg\(dg
  3981. that are in the format of a variable assignment,
  3982. are expanded with the same rules as a variable assignment.
  3983. This means that
  3984. tilde substitution is performed after the
  3985. .B =
  3986. sign and field splitting and file name generation are not
  3987. performed.
  3988. .PD
  3989. .TP
  3990. \(dg \f3:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  3991. The command only expands parameters.
  3992. .br
  3993. .ne 2
  3994. .TP
  3995. \(dg \f3\|. \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  3996. If
  3997. .I name\^
  3998. is a function defined with the
  3999. .B function
  4000. .I name\^
  4001. reserved word syntax,
  4002. the function is executed in the current environment
  4003. ( as if it had been defined with the
  4004. .IB name ()
  4005. syntax.)
  4006. Otherwise if
  4007. .I name\^
  4008. refers to a file, the
  4009. file is read in its entirety and the commands are
  4010. executed in the current shell environment.
  4011. The search path
  4012. specified by
  4013. .B
  4014. .SM PATH
  4015. is used to find the directory containing file.
  4016. If any arguments
  4017. .I arg\^
  4018. are given,
  4019. they become the positional parameters while processing
  4020. the
  4021. .B .
  4022. command and are restored upon completion.
  4023. Otherwise the positional parameters are unchanged.
  4024. The exit status is the exit status of the last command executed.
  4025. .TP
  4026. \(dg\(dg \f3alias\fP \*(OK \f3\-ptx\fP \*(CK \*(OK \f2name\fP\*(OK \f3=\fP\f2value\^\fP \*(CK \*(CK .\|.\|.
  4027. .B alias\^
  4028. with no arguments prints the list of aliases
  4029. in the form
  4030. .I name=value\^
  4031. on standard output.
  4032. The
  4033. .B \-p
  4034. option
  4035. causes the word
  4036. .B alias
  4037. to be inserted before each one.
  4038. When one or more arguments are given
  4039. an
  4040. .I alias\^
  4041. is defined
  4042. for each
  4043. .I name\^
  4044. whose
  4045. .I value\^
  4046. is given.
  4047. A trailing space in
  4048. .I value\^
  4049. causes the next word to be checked for
  4050. alias substitution.
  4051. The obsolete
  4052. .B \-t
  4053. option is used to set and list tracked aliases.
  4054. The value of a tracked alias is the full pathname
  4055. corresponding to the given
  4056. .IR name .
  4057. The value becomes undefined when the value of
  4058. .SM
  4059. .B PATH
  4060. is reset but the alias remains tracked.
  4061. Without the
  4062. .B \-t
  4063. option,
  4064. for each
  4065. .I name\^
  4066. in the argument list
  4067. for which no
  4068. .I value\^
  4069. is given, the name
  4070. and value of the alias is printed.
  4071. The obsolete
  4072. .B \-x
  4073. option has no effect.
  4074. The exit status is non-zero if a
  4075. .I name\^
  4076. is given, but no value, and no alias has been defined for the
  4077. .IR name\^ .
  4078. .TP
  4079. \f3bg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
  4080. This command is only on systems that support job control.
  4081. Puts each specified
  4082. .I job\^
  4083. into the background.
  4084. The current job is put in the background
  4085. if
  4086. .I job\^
  4087. is not specified.
  4088. See
  4089. .I Jobs
  4090. for a description of the format of
  4091. .IR job .
  4092. .TP
  4093. \(dg \f3break\fP \*(OK \f2n\^\fP \*(CK
  4094. Exit from the enclosing
  4095. .BR for\^ ,
  4096. .BR while\^ ,
  4097. .BR until\^ ,
  4098. or
  4099. .B select\^
  4100. loop, if any.
  4101. If
  4102. .I n\^
  4103. is specified then break
  4104. .I n\^
  4105. levels.
  4106. .TP
  4107. \f3builtin\fP \*(OK \f3\-ds\fP \*(CK \*(OK \f3\-f\fP \f2file\^\fP \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
  4108. If
  4109. .I name\^
  4110. is not specified, the built-ins are printed on standard output.
  4111. The
  4112. .B \-s
  4113. option prints only the special built-ins.
  4114. Otherwise, each
  4115. .I name\^
  4116. represents the pathname whose basename is the name of the built-in.
  4117. The entry point function name is determined by prepending
  4118. .B b_
  4119. to the built-in name.
  4120. Special built-ins cannot be bound to a pathname or deleted.
  4121. The
  4122. .B \-d
  4123. option deletes each of the given built-ins.
  4124. On systems that support dynamic loading, the
  4125. .B \-f
  4126. option names a shared library containing the code for built-ins.
  4127. Once a library is loaded, its symbols become available
  4128. for subsequent invocations of
  4129. .BR builtin .
  4130. Multiple libraries can be specified with separate invocations
  4131. of the
  4132. .B builtin
  4133. command.
  4134. Libraries are searched in the reverse order in which they are specified.
  4135. .TP
  4136. .PD 0
  4137. \f3cd\fP \*(OK \f3\-LP\fP \*(CK \*(OK \f2arg\^\fP \*(CK
  4138. .TP
  4139. \f3cd\fP \*(OK \f3\-LP\fP \*(CK \f2old\^\fP \f2new\^\fP
  4140. .PD
  4141. This command can be in either of two forms.
  4142. In the first form it
  4143. changes the current directory to
  4144. .IR arg .
  4145. If
  4146. .I arg\^
  4147. is
  4148. .B \-
  4149. the directory is changed to the previous
  4150. directory.
  4151. The shell
  4152. variable
  4153. .B
  4154. .SM HOME
  4155. is the default
  4156. .IR arg .
  4157. The variable
  4158. .SM
  4159. .B PWD
  4160. is set to the current directory.
  4161. The shell variable
  4162. .B
  4163. .SM CDPATH
  4164. defines the search path for
  4165. the directory containing
  4166. .IR arg .
  4167. Alternative directory names are separated by
  4168. a colon
  4169. .RB ( : ).
  4170. The default path is
  4171. .B <null>
  4172. (specifying the current directory).
  4173. Note that the current directory is specified by a null path name,
  4174. which can appear immediately after the equal sign
  4175. or between the colon delimiters anywhere else in the path list.
  4176. If
  4177. .I arg
  4178. begins with a \f3/\fP then the search path
  4179. is not used.
  4180. Otherwise, each directory in the path is
  4181. searched for
  4182. .IR arg .
  4183. .P
  4184. The obsolete second form of
  4185. .B cd
  4186. substitutes the string
  4187. .I new
  4188. for the string
  4189. .I old
  4190. in the current directory name,
  4191. .SM
  4192. .B PWD
  4193. and tries to change to this new directory.
  4194. .P
  4195. By default, symbolic links are not followed when
  4196. finding the directory name.
  4197. This is equivalent to the
  4198. .B \-L
  4199. option.
  4200. The
  4201. .B \-P
  4202. option causes
  4203. symbolic links to be followed when determining the directory.
  4204. The last instance of
  4205. .B \-L
  4206. or
  4207. .B \-P
  4208. determines which method is used.
  4209. .P
  4210. The
  4211. .B cd\^
  4212. command may not be executed by
  4213. .if \nZ=0 .B rsh\^.
  4214. .if \nZ=1 .B rksh\^.
  4215. .TP
  4216. \f3command\fP \*(OK \f3\-pvV\fP \*(CK \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4217. Without the
  4218. .B \-v
  4219. or
  4220. .B \-V
  4221. options,
  4222. .B command
  4223. executes
  4224. .I name\^
  4225. with the arguments given by
  4226. .IR arg .
  4227. The
  4228. .B \-p
  4229. option causes
  4230. a default path to be searched
  4231. rather than the one defined by the value of
  4232. .SM
  4233. .BR PATH .
  4234. Functions will not be searched for when finding
  4235. .IR name .
  4236. In addition, if
  4237. .I name\^
  4238. refers to a special built-in,
  4239. none of the special properties associated with the leading
  4240. daggers will be honored.
  4241. (
  4242. For example, the predefined alias
  4243. .B "redirect=\(fmcommand exec\(fm"
  4244. prevents a script from terminating when an invalid
  4245. redirection is given.)
  4246. With the
  4247. .B \-v
  4248. option,
  4249. .B command
  4250. is equivalent to the built-in
  4251. .B whence
  4252. command described below.
  4253. The
  4254. .B \-V
  4255. options, causes
  4256. .B command
  4257. to
  4258. .BR "whence \-v" .
  4259. .TP
  4260. \(dg \f3continue\fP \*(OK \f2n\^\fP \*(CK
  4261. Resume the next iteration of the enclosing
  4262. .BR for\^ ,
  4263. .BR while\^ ,
  4264. .BR until\^ ,
  4265. or
  4266. .B select\^
  4267. loop.
  4268. If
  4269. .I n\^
  4270. is specified then resume at the
  4271. .IR n -th
  4272. enclosing loop.
  4273. .TP
  4274. \f3disown\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
  4275. Causes the shell not to send a HUP signal to
  4276. each given
  4277. .IR job ,
  4278. or all active jobs if
  4279. .I job
  4280. is omitted,
  4281. when a login shell terminates.
  4282. .TP
  4283. \f3echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4284. When the first
  4285. .I arg\^
  4286. does not begin with a \-, and
  4287. none of the arguments contain a \e,
  4288. then
  4289. .B echo
  4290. prints each of its arguments separated by a space
  4291. and terminated by a new-line.
  4292. Otherwise, the behavior of
  4293. .B echo
  4294. is system dependent
  4295. and
  4296. .B print
  4297. or
  4298. .B printf
  4299. described below should be used.
  4300. See
  4301. .IR echo (1)
  4302. for usage and description.
  4303. .TP
  4304. \(dg \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4305. The arguments are read as input
  4306. to the shell
  4307. and the resulting command(s) executed.
  4308. .TP
  4309. \(dg \f3exec\fP \*(OK \f3\-c\fP \*(CK \*(OK \f3\-a\fP \f2name\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4310. If
  4311. .I arg\^
  4312. is given,
  4313. the command specified by
  4314. the arguments is executed in place of this shell
  4315. without creating a new process.
  4316. The
  4317. .B \-c
  4318. option causes the environment to be cleared before applying
  4319. variable assignments associated with the
  4320. .B exec
  4321. invocation.
  4322. The
  4323. .B \-a
  4324. option
  4325. causes
  4326. .I name\^
  4327. rather than the first
  4328. .IR arg ,
  4329. to become
  4330. .B argv[0]
  4331. for the new process.
  4332. Input/output arguments may appear and
  4333. affect the current process.
  4334. If
  4335. .I arg\^
  4336. is not given
  4337. the effect of this command is to
  4338. modify file descriptors
  4339. as prescribed by the input/output redirection list.
  4340. In this case,
  4341. any file descriptor numbers greater than 2 that are
  4342. opened with this mechanism are closed when invoking
  4343. another program.
  4344. .TP
  4345. \(dg \f3exit\fP \*(OK \f2n\^\fP \*(CK
  4346. Causes the shell to exit
  4347. with the exit status specified by
  4348. .IR n .
  4349. The value will be the least significant 8 bits of the specified status.
  4350. If
  4351. .I n\^
  4352. is omitted then the exit status is that of the last command executed.
  4353. An end-of-file will also cause the shell to exit
  4354. except for a
  4355. shell which has the
  4356. .I ignoreeof
  4357. option (see
  4358. .B set
  4359. below) turned on.
  4360. .TP
  4361. \(dg\(dg \f3export\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2name\^\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
  4362. If
  4363. .I name\^
  4364. is not given,
  4365. the names and values of each variable with
  4366. the export attribute are printed with the values
  4367. quoted in a manner that allows them to be re-inputed.
  4368. The
  4369. .B \-p
  4370. option
  4371. causes the word
  4372. .B export
  4373. to be inserted before each one.
  4374. Otherwise, the given
  4375. .IR name s
  4376. are marked for automatic
  4377. export to the
  4378. .I environment\^
  4379. of subsequently-executed commands.
  4380. .TP
  4381. \f3fg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
  4382. This command is only on systems that support job control.
  4383. Each
  4384. .I job\^
  4385. specified is brought to the foreground and waited for in
  4386. the specified order.
  4387. Otherwise, the current job is
  4388. brought into the foreground.
  4389. See
  4390. .I Jobs
  4391. for a description of the format of
  4392. .IR job .
  4393. .TP
  4394. \f3getconf\fP \f2name\^\fP \*(OK \f2pathname\^\fP \*(CK
  4395. Prints the current value of the configuration parameter given by
  4396. .IR name .
  4397. .TP
  4398. \f3getopts\fP \f2optstring vname\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4399. Checks
  4400. .I arg
  4401. for legal options.
  4402. If
  4403. .I arg
  4404. is omitted,
  4405. the positional parameters are used.
  4406. An option argument begins with a
  4407. .B +
  4408. or a
  4409. .BR \- .
  4410. An option not beginning with
  4411. .B +
  4412. or
  4413. .B \-
  4414. or the argument
  4415. .B \-\|\-
  4416. ends the options.
  4417. .I optstring
  4418. contains the letters that
  4419. .I getopts
  4420. recognizes.
  4421. If a letter is followed by a
  4422. .BR : ,
  4423. that option is expected to have an argument.
  4424. The options can be separated from the argument by blanks.
  4425. .P
  4426. .B
  4427. getopts
  4428. places the next option letter it finds inside variable
  4429. .I vname\^
  4430. each time it is invoked with a
  4431. .B +
  4432. prepended when
  4433. .I arg
  4434. begins with a
  4435. .BR + .
  4436. The index of the next
  4437. .I arg
  4438. is stored in
  4439. .SM
  4440. .BR OPTIND .
  4441. The option argument,
  4442. if any,
  4443. gets stored in
  4444. .SM
  4445. .BR OPTARG .
  4446. .P
  4447. A leading
  4448. .B :
  4449. in
  4450. .I optstring
  4451. causes
  4452. .B getopts
  4453. to store the letter of an invalid
  4454. option in
  4455. .SM
  4456. .BR OPTARG ,
  4457. and to set
  4458. .I vname
  4459. to
  4460. .B ?
  4461. for an unknown option and to
  4462. .B :
  4463. when a required option is missing.
  4464. Otherwise,
  4465. .B getopts
  4466. prints an error message.
  4467. The exit status is non-zero when there are no more options.
  4468. .P
  4469. There is no way to specify any of the options
  4470. .BR : ,
  4471. .BR + ,
  4472. .BR \- ,
  4473. .BR ? ,
  4474. .BR [ ,
  4475. and
  4476. .BR ] .
  4477. The option
  4478. .B #
  4479. can only be specified as the first option.
  4480. .TP
  4481. .PD 0
  4482. \f3hist\fP \*(OK \f3\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f3\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
  4483. .TP
  4484. \f3hist \-s \fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
  4485. .PD
  4486. In the first form,
  4487. a range of commands from
  4488. .I first\^
  4489. to
  4490. .I last\^
  4491. is selected from the last
  4492. .SM
  4493. .B HISTSIZE
  4494. commands that were typed at the terminal.
  4495. The arguments
  4496. .I first\^
  4497. and
  4498. .I last\^
  4499. may be specified as a number or as a string.
  4500. A string is used to locate the most recent command starting with
  4501. the given string.
  4502. A negative number is used as an offset to the current command number.
  4503. If the
  4504. .B \-l
  4505. option
  4506. is selected,
  4507. the commands are listed on standard output.
  4508. Otherwise, the editor program
  4509. .I ename\^
  4510. is invoked on a file containing these
  4511. keyboard commands.
  4512. If
  4513. .I ename\^
  4514. is not supplied, then the value of the variable
  4515. .SM
  4516. .B HISTEDIT
  4517. is used.
  4518. If
  4519. .SM
  4520. .B HISTEDIT
  4521. is not set then
  4522. .SM
  4523. .B FCEDIT
  4524. (default
  4525. .BR /bin/ed\^ )
  4526. is used as the editor.
  4527. When editing is complete, the edited command(s)
  4528. is executed if the changes have been saved.
  4529. If
  4530. .I last\^
  4531. is not specified
  4532. then it will be set to
  4533. .IR first .
  4534. If
  4535. .I first\^
  4536. is not specified
  4537. the default is the previous command
  4538. for editing and \-16 for listing.
  4539. The option
  4540. .B \-r
  4541. reverses the order of the commands and
  4542. the option
  4543. .B \-n
  4544. suppresses command numbers when listing.
  4545. In the second form the
  4546. .I command\^
  4547. is re-executed after the substitution
  4548. \f2old\^\fP\f3=\fP\f2new\^\fP
  4549. is performed.
  4550. .TP
  4551. \f3jobs\fP \*(OK \f3\-lnp\^\fP \*(CK \*(OK \f2job\^\fP \.\|.\|. \*(CK
  4552. Lists information about each given job; or all active jobs if
  4553. .I job
  4554. is omitted.
  4555. The
  4556. .B \-l
  4557. option lists process ids in addition to the normal information.
  4558. The
  4559. .B \-n
  4560. option only displays jobs that have stopped or exited since last
  4561. notified.
  4562. The
  4563. .B \-p
  4564. option causes only the process group to be listed.
  4565. See
  4566. .I Jobs
  4567. for a description of the format of
  4568. .IR job .
  4569. .TP
  4570. .PD 0
  4571. \f3kill\fP \*(OK \f3\-s\fP \f2signame\^\fP \*(CK \f2job\^\fP .\|.\|.
  4572. .TP
  4573. .PD 0
  4574. \f3kill\fP \*(OK \f3\-n\fP \f2signum\^\fP \*(CK \f2job\^\fP .\|.\|.
  4575. .TP
  4576. \f3kill\fP \f3\-l\fP \*(OK \f2sig\^\fP .\|.\|. \*(CK
  4577. .PD
  4578. Sends either the TERM (terminate) signal or the
  4579. specified signal to the specified jobs or processes.
  4580. Signals are either given by number with the
  4581. .B \-n
  4582. option or by name with the
  4583. .B \-s
  4584. option
  4585. (as given in
  4586. .BR <signal.h> ,
  4587. stripped of the prefix ``SIG'' with
  4588. the exception that SIGCLD is named CHLD).
  4589. For backward compatibility, the
  4590. .B n
  4591. and
  4592. .B s
  4593. can be omitted and the number or name placed immediately
  4594. after the
  4595. .BR \- .
  4596. If the signal being sent is TERM (terminate) or HUP (hangup),
  4597. then the job or process will be sent a CONT (continue) signal
  4598. if it is stopped.
  4599. The argument
  4600. .I job\^
  4601. can be the process id of a process that is not a member of one of the
  4602. active jobs.
  4603. See
  4604. .I Jobs
  4605. for a description of the format of
  4606. .IR job .
  4607. In the third form,
  4608. .BR "kill \-l" ,
  4609. if
  4610. .I sig\^
  4611. is not specified,
  4612. the signal names are listed.
  4613. Otherwise, for each
  4614. .I sig\^
  4615. that is a name, the corresponding signal number is listed.
  4616. For each
  4617. .I sig\^
  4618. that is a number, the signal name corresponding to the
  4619. least significant 8 bits of
  4620. .I sig\^
  4621. is listed.
  4622. .TP
  4623. \f3let\fP \f2arg\^\fP .\|.\|.
  4624. Each
  4625. .I arg
  4626. is a separate
  4627. .I "arithmetic expression"
  4628. to be evaluated.
  4629. See
  4630. .I "Arithmetic Evaluation"
  4631. above, for a description of arithmetic expression evaluation.
  4632. .P
  4633. The exit status is
  4634. 0 if the value of the last expression
  4635. is non-zero, and 1 otherwise.
  4636. .TP
  4637. \(dg \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4638. Equivalent to
  4639. .BI "exec /bin/newgrp" " arg\^"
  4640. \&.\|.\|.\^.
  4641. .TP
  4642. \f3print\fP \*(OK \f3\-Rnprs\^\fP \*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f3\-f\fP \f2format\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4643. With no options or with option
  4644. .B \-
  4645. or
  4646. .BR \-\|\- ,
  4647. Each
  4648. .I arg
  4649. is printed
  4650. on standard output.
  4651. The
  4652. .B \-f
  4653. option causes the arguments to be printed as
  4654. described by
  4655. .BR printf .
  4656. In this case any
  4657. .BR n ,
  4658. .BR r ,
  4659. .B R
  4660. options are ignored.
  4661. Otherwise,
  4662. unless the
  4663. .B \-R
  4664. or
  4665. .BR \-r ,
  4666. are specified, the following
  4667. escape conventions will be applied:
  4668. .RS
  4669. .PD 0
  4670. .TP
  4671. .B \ea
  4672. The alert character (ascii
  4673. .BR 07 ).
  4674. .TP
  4675. .B \eb
  4676. The backspace character (ascii
  4677. .BR 010 ).
  4678. .TP
  4679. .B \ec
  4680. Causes
  4681. .B print
  4682. to end without processing more arguments and
  4683. not adding a new-line.
  4684. .TP
  4685. .B \ef
  4686. The formfeed character (ascii
  4687. .BR 014 ).
  4688. .TP
  4689. .B \en
  4690. The new-line character (ascii
  4691. .BR 012 ).
  4692. .TP
  4693. .B \er
  4694. The carriage return character (ascii
  4695. .BR 015 ).
  4696. .TP
  4697. .B \et
  4698. The tab character (ascii
  4699. .BR 011 ).
  4700. .TP
  4701. .B \ev
  4702. The vertical tab character (ascii
  4703. .BR 013 ).
  4704. .TP
  4705. .B \eE
  4706. The escape character (ascii
  4707. .BR 033 ).
  4708. .TP
  4709. .B \e\e
  4710. The backslash character \e.
  4711. .PD
  4712. .PP
  4713. The
  4714. .B \-R
  4715. option will print all subsequent arguments and options
  4716. other than
  4717. .BR \-n .
  4718. The
  4719. .B \-p
  4720. option causes the
  4721. arguments to be written onto the pipe
  4722. of the process spawned with
  4723. .B \(bv&
  4724. instead of standard output.
  4725. The
  4726. .B \-s
  4727. option causes the
  4728. arguments to be written onto the history file
  4729. instead of standard output.
  4730. The
  4731. .B \-u
  4732. option can be used to specify a one digit
  4733. file descriptor unit number
  4734. .I unit\^
  4735. on which the
  4736. output will be placed.
  4737. The default is 1.
  4738. If the option
  4739. .B \-n
  4740. is used, no
  4741. .B new-line\^
  4742. is added to the output.
  4743. .RE
  4744. .TP
  4745. \f3printf\fP \f2format\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4746. The arguments
  4747. .I arg\^
  4748. are printed on standard output
  4749. in accordance with the ANSI-C
  4750. formatting rules associated with the format string
  4751. .IR format .
  4752. The following extensions can also be used:
  4753. .BL
  4754. .LI
  4755. A
  4756. .B %b
  4757. format can be used instead of
  4758. .B %s
  4759. to cause escape sequences in the corresponding
  4760. .I arg\^
  4761. to be expanded as described in
  4762. .BR print.
  4763. .LI
  4764. A
  4765. .B %P
  4766. format can be used instead of
  4767. .B %s
  4768. to cause
  4769. .I arg\^
  4770. to be interpreted as an extended regular
  4771. expression and be printed as a shell pattern.
  4772. .LI
  4773. A
  4774. .B %q
  4775. format can be used instead of
  4776. .B %s
  4777. to cause the resulting string to be quoted in a manner than can
  4778. be reinput to the shell.
  4779. .LI
  4780. The precision field of the
  4781. .B %d
  4782. format can be followed by a
  4783. .B .
  4784. and the output base.
  4785. .LE
  4786. .TP
  4787. \f3pwd\fP \*(OK \f3\-LP\fP \*(CK
  4788. Outputs the value of the current working
  4789. directory.
  4790. If the
  4791. .B \-P
  4792. option is given,
  4793. all symbolic links are resolved from the name.
  4794. .TP
  4795. \f3read\fP \*(OK \f3\-Aprs\^\fP \*(CK \*(OK \f3\-d\fP \f2delim\^\fP\*(CK \*(OK \f3\-t\fP \f2timeout\^\fP\*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
  4796. The shell input mechanism.
  4797. One line is read and
  4798. is broken up into fields using the characters in
  4799. .B
  4800. .SM IFS
  4801. as separators.
  4802. The escape character,
  4803. .BR \e ,
  4804. is used to remove any special meaning for the next
  4805. character and for line continuation.
  4806. The
  4807. .B \-d
  4808. option
  4809. causes the read to continue to the first character of
  4810. .I delim\^
  4811. rather than new-line.
  4812. In raw mode,
  4813. .B \-r,
  4814. the
  4815. .B \e
  4816. character is not treated specially.
  4817. The first
  4818. field is assigned to the first
  4819. .IR vname ,
  4820. the second field
  4821. to the second
  4822. .IR vname ,
  4823. etc., with leftover fields assigned to the last
  4824. .IR vname .
  4825. The
  4826. .B \-A
  4827. option causes the variable
  4828. .I vname\^
  4829. to be unset and each field that is read to be stored in
  4830. successive elements of the indexed array
  4831. .IR vname.
  4832. The
  4833. .B \-p
  4834. option causes the input line
  4835. to be taken from the input pipe
  4836. of a process spawned by the shell
  4837. using
  4838. .BR \(bv& .
  4839. If the
  4840. .B \-s
  4841. option is present,
  4842. the input will be saved as a command in the history file.
  4843. The option
  4844. .B \-u
  4845. can be used to specify a one digit file
  4846. descriptor unit
  4847. .I unit\^
  4848. to read from.
  4849. The file descriptor can be opened with the
  4850. .B exec\^
  4851. special built-in command.
  4852. The default value of unit
  4853. .I n\^
  4854. is 0.
  4855. The option
  4856. .B \-t
  4857. is used to specify a timeout in decimal
  4858. seconds when reading from a terminal or pipe.
  4859. If
  4860. .I vname\^
  4861. is omitted then
  4862. .SM
  4863. .B REPLY
  4864. is used as the default
  4865. .IR vname .
  4866. An end-of-file with the
  4867. .B \-p
  4868. option causes cleanup for this process
  4869. so that another can be spawned.
  4870. If the first argument contains a
  4871. .BR ? ,
  4872. the remainder of this word is used as a
  4873. .I prompt\^
  4874. on standard error
  4875. when the shell is interactive.
  4876. The exit status is 0 unless an end-of-file is encountered
  4877. or read has timed out.
  4878. .TP
  4879. \(dg\(dg \f3readonly\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
  4880. If
  4881. .I vname\^
  4882. is not given
  4883. the names and values of each variable with
  4884. the readonly attribute is printed with the values
  4885. quoted in a manner that allows them to be re-inputed.
  4886. The
  4887. .B \-p
  4888. option
  4889. causes the word
  4890. .B readonly
  4891. to be inserted before each one.
  4892. Otherwise, the given
  4893. .IR vname s
  4894. are marked
  4895. readonly and these
  4896. names cannot be changed
  4897. by subsequent assignment.
  4898. .TP
  4899. \(dg \f3return\fP \*(OK \f2n\^\fP \*(CK
  4900. Causes a shell
  4901. .I function
  4902. or
  4903. \f3\|.\fP
  4904. script to return
  4905. to the invoking script
  4906. with the return status specified by
  4907. .IR n .
  4908. The value will be the least significant 8 bits of the specified status.
  4909. If
  4910. .I n\^
  4911. is omitted then the return status is that of the last command executed.
  4912. If
  4913. .B return
  4914. is invoked while not in a
  4915. .I function
  4916. or a
  4917. \f3\|.\fP
  4918. script,
  4919. then it behaves the same as
  4920. .BR exit .
  4921. .TP
  4922. \(dg \f3set\fP \*(OK \f3\(+-CPabefhkmnopstuvx\fP \*(CK \*(OK \f3\(+-o\fP \f2option\^\fP \*(CK.\|.\|. \*(OK \f3\(+-A\fP \f2vname\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
  4923. The options for this command have meaning as follows:
  4924. .RS
  4925. .PD 0
  4926. .TP 8
  4927. .B \-A
  4928. Array assignment.
  4929. Unset the variable
  4930. .I vname
  4931. and assign values sequentially from the
  4932. list
  4933. .IR arg .
  4934. If
  4935. .B +A
  4936. is used, the variable
  4937. .I vname
  4938. is not unset first.
  4939. .TP 8
  4940. .B \-C
  4941. Prevents redirection
  4942. .B >
  4943. from truncating existing files.
  4944. Files that are created are opened with the O_EXCL mode.
  4945. Require
  4946. .B >\(bv
  4947. to truncate a file when turned on.
  4948. .TP 8
  4949. .B \-P
  4950. Causes the
  4951. .B cd
  4952. and
  4953. .B pwd
  4954. built-in commands to default to physical mode.
  4955. .TP 8
  4956. .B \-a
  4957. All subsequent variables that are defined are automatically exported.
  4958. .TP 8
  4959. .B \-b
  4960. Prints job completion messages as soon as a background job changes
  4961. state rather than waiting for the next prompt.
  4962. .TP 8
  4963. .B \-e
  4964. If a command has a non-zero exit status,
  4965. execute the
  4966. .SM
  4967. .B ERR
  4968. trap, if set,
  4969. and exit.
  4970. This mode is disabled while reading profiles.
  4971. .TP 8
  4972. .B \-f
  4973. Disables file name generation.
  4974. .TP 8
  4975. .B \-h
  4976. Each command
  4977. becomes a tracked alias when first encountered.
  4978. .TP 8
  4979. .B \-k
  4980. (Obsolete). All variable assignment arguments are placed in the environment for a command,
  4981. not just those that precede the command name.
  4982. .TP 8
  4983. .B \-m
  4984. Background jobs will run in a separate process group
  4985. and a line will print upon completion.
  4986. The exit status of background jobs is reported in a completion message.
  4987. On systems with job control,
  4988. this option is turned on automatically for
  4989. interactive shells.
  4990. .TP 8
  4991. .B \-n
  4992. Read commands and check them for syntax errors, but do not execute them.
  4993. Ignored for interactive shells.
  4994. .TP 8
  4995. .B \-o
  4996. The following argument can be one of the following option names:
  4997. .RS
  4998. .TP 8
  4999. .B allexport
  5000. Same as
  5001. .BR \-a .
  5002. .TP 8
  5003. .B errexit
  5004. Same as
  5005. .BR \-e .
  5006. .TP 8
  5007. .B bgnice
  5008. All background jobs are run at a lower priority.
  5009. This is the default mode.
  5010. .TP 8
  5011. .B emacs
  5012. Puts you in an
  5013. .I emacs
  5014. style in-line editor for command entry.
  5015. .TP 8
  5016. .B gmacs
  5017. Puts you in a
  5018. .I gmacs
  5019. style in-line editor for command entry.
  5020. .TP 8
  5021. .B ignoreeof
  5022. The shell will not exit on end-of-file.
  5023. The command
  5024. .B exit
  5025. must be used.
  5026. .TP 8
  5027. .B keyword
  5028. Same as
  5029. .BR \-k .
  5030. .TP 8
  5031. .B markdirs
  5032. All directory names resulting from file name generation have a trailing
  5033. .B /
  5034. appended.
  5035. .TP 8
  5036. .B monitor
  5037. Same as
  5038. .BR \-m .
  5039. .TP 8
  5040. .B noclobber
  5041. Same as
  5042. .BR \-C .
  5043. .TP 8
  5044. .B noexec
  5045. Same as
  5046. .BR \-n .
  5047. .TP 8
  5048. .B noglob
  5049. Same as
  5050. .BR \-f .
  5051. .TP 8
  5052. .B nolog
  5053. Do not save function definitions in history file.
  5054. .TP 8
  5055. .B notify
  5056. Same as
  5057. .BR \-b .
  5058. .TP 8
  5059. .B nounset
  5060. Same as
  5061. .BR \-u .
  5062. .TP 8
  5063. .B physical
  5064. Same as
  5065. .BR \-P .
  5066. .TP 8
  5067. .B privileged
  5068. Same as
  5069. .BR \-p .
  5070. .TP 8
  5071. .B verbose
  5072. Same as
  5073. .BR \-v .
  5074. .TP 8
  5075. .B trackall
  5076. Same as
  5077. .BR \-h .
  5078. .TP 8
  5079. .B vi
  5080. Puts you in insert mode of a
  5081. .I vi\^
  5082. style in-line editor
  5083. until you hit escape character
  5084. .BR 033 .
  5085. This puts you in control mode.
  5086. A return sends the line.
  5087. .TP 8
  5088. .B viraw
  5089. Each character is processed as it is typed
  5090. in
  5091. .I vi\^
  5092. mode.
  5093. .TP 8
  5094. .B xtrace
  5095. Same as
  5096. .BR \-x .
  5097. .TP 8
  5098. If no option name is supplied then the current option settings are printed.
  5099. .RE
  5100. .TP 8
  5101. .B \-p
  5102. Disables processing of the
  5103. .B \s-1$HOME\s+1/.profile
  5104. file and uses the file
  5105. .B /etc/suid_profile
  5106. instead of the
  5107. .SM
  5108. .B ENV
  5109. file.
  5110. This mode is on whenever the effective uid (gid)
  5111. is not equal to the real uid (gid).
  5112. Turning this off causes the effective uid and gid to be
  5113. set to the real uid and gid.
  5114. .TP 8
  5115. .B \-s
  5116. Sort the positional parameters lexicographically.
  5117. .TP 8
  5118. .B \-t
  5119. (Obsolete). Exit after reading and executing one command.
  5120. .TP 8
  5121. .B \-u
  5122. Treat unset parameters as an error when substituting.
  5123. .TP 8
  5124. .B \-v
  5125. Print shell input lines as they are read.
  5126. .TP 8
  5127. .B \-x
  5128. Print commands and their arguments as they are executed.
  5129. .TP 8
  5130. .B \-\|\-
  5131. Do not change any of the options; useful in setting
  5132. .B $1
  5133. to a value beginning with
  5134. .BR \- .
  5135. If no arguments follow this option then the positional parameters are unset.
  5136. .PD
  5137. .PP
  5138. As an obsolete feature,
  5139. if the first
  5140. .I arg\^
  5141. is
  5142. .B \-
  5143. then the
  5144. .B \-x
  5145. and
  5146. .B \-v
  5147. options are turned off and the next
  5148. .I arg
  5149. is treated as the first argument.
  5150. Using
  5151. .B \+
  5152. rather than
  5153. .B \-
  5154. causes these options to be turned off.
  5155. These options can also be used upon invocation of the shell.
  5156. The current set of options may be found in
  5157. .BR $\- .
  5158. Unless
  5159. .B \-A
  5160. is specified,
  5161. the remaining arguments are positional
  5162. parameters and are assigned, in order, to
  5163. .B $1
  5164. .B $2
  5165. \&.\|.\|.\^.
  5166. If no arguments are given then the names and values
  5167. of all variables are printed on the standard output.
  5168. .RE
  5169. .TP
  5170. \(dg \f3shift\fP \*(OK \f2n\^\fP \*(CK
  5171. .br
  5172. The positional parameters from
  5173. \f3$\fP\f2n\fP\f3+1\fP
  5174. \&.\|.\|.
  5175. are renamed
  5176. .B $1
  5177. \&.\|.\|.\^
  5178. , default
  5179. .I n\^
  5180. is 1.
  5181. The parameter
  5182. .I n\^
  5183. can be any arithmetic expression that evaluates to a non-negative
  5184. number less than or equal to
  5185. .BR $# .
  5186. .TP
  5187. \f3sleep\fP \f2seconds\^\fP
  5188. Suspends execution for the number of decimal seconds or fractions of a
  5189. second given by
  5190. .IR seconds .
  5191. .TP
  5192. \(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
  5193. The \-p
  5194. option causes the trap
  5195. action associated with each trap as specified by the arguments
  5196. to be printed with appropriate quoting.
  5197. Otherwise,
  5198. .I action\^
  5199. will be processed as if it were an argument to
  5200. .B eval
  5201. when the shell
  5202. receives signal(s)
  5203. .IR sig .
  5204. Each
  5205. .I sig\^
  5206. can be given as a number or as the name of the signal.
  5207. Trap commands are executed in order of signal number.
  5208. Any attempt to set a trap on a signal that
  5209. was ignored on entry to the current shell
  5210. is ineffective.
  5211. If
  5212. .I action\^
  5213. is omitted and the first
  5214. .I sig\^
  5215. is a number, or if
  5216. .I action\^
  5217. is
  5218. .BR \- ,
  5219. then the trap(s) for each
  5220. .I sig\^
  5221. are reset
  5222. to their original values.
  5223. If
  5224. .I action\^
  5225. is the null
  5226. string then this signal is ignored by the shell and by the commands
  5227. it invokes.
  5228. If
  5229. .I sig\^
  5230. is
  5231. .SM
  5232. .B ERR
  5233. then
  5234. .I action\^
  5235. will be executed whenever a command has a non-zero exit status.
  5236. If
  5237. .I sig\^
  5238. is
  5239. .SM
  5240. .B DEBUG
  5241. then
  5242. .I action\^
  5243. will be executed before each command.
  5244. If
  5245. .I sig\^
  5246. is
  5247. .B 0
  5248. or
  5249. .SM
  5250. .B EXIT
  5251. and the
  5252. .B trap
  5253. statement is executed inside the body of a function,
  5254. then the command
  5255. .I action\^
  5256. is executed
  5257. after the function completes.
  5258. If
  5259. .I sig\^
  5260. is
  5261. .B 0
  5262. or
  5263. .SM
  5264. .B EXIT
  5265. for a
  5266. .B trap
  5267. set outside any function
  5268. then the command
  5269. .I action\^
  5270. is executed
  5271. on exit from the shell.
  5272. If
  5273. .I sig\^
  5274. is
  5275. .SM
  5276. .B KEYBD
  5277. then
  5278. .I action\^
  5279. will be executed whenever a key is read
  5280. while in
  5281. .BR emacs ,
  5282. .BR gmacs ,
  5283. or
  5284. .B vi\^
  5285. mode.
  5286. The
  5287. .B trap
  5288. command
  5289. with no arguments prints a list
  5290. of commands associated with each signal number.
  5291. .TP
  5292. \(dg\(dg \f3typeset\fP \*(OK \f3\(+-AHflnprtux\^\fP \*(CK \*(OK \f3\(+-EFLRZi\*(OK\f2n\^\fP\*(CK \*(CK \*(OK \f2vname\^\fP\*(OK\f3=\fP\f2value\^\fP \*(CK \^ \*(CK .\|.\|.
  5293. Sets attributes and values for shell variables and functions.
  5294. When invoked inside a function,
  5295. a new instance of the variables
  5296. .I vname\^
  5297. is created.
  5298. The variables' value and type are restored
  5299. when the function completes.
  5300. The following list of attributes may be specified:
  5301. .RS
  5302. .PD 0
  5303. .TP
  5304. .B \-A
  5305. Declares
  5306. .I vname\^
  5307. to be an associate array.
  5308. Subscripts are strings rather than arithmetic
  5309. expressions.
  5310. .TP
  5311. .B \-E
  5312. Declares
  5313. .I vname\^
  5314. to be a double precision floating point number.
  5315. If
  5316. .I n\^
  5317. is non-zero it defines the number of significant figures
  5318. that are used when expanding
  5319. .IR vname .
  5320. Otherwise ten significant figures will be used.
  5321. .TP
  5322. .B \-F
  5323. Declares
  5324. .I vname\^
  5325. to be a double precision floating point number.
  5326. If
  5327. .I n\^
  5328. is non-zero it defines the number of places after the
  5329. decimal point that are used when expanding
  5330. .IR vname .
  5331. Otherwise ten places after the decimal point will be used.
  5332. .TP
  5333. .B \-H
  5334. This option provides UNIX to host-name file mapping on non-UNIX
  5335. machines.
  5336. .TP
  5337. .B \-L
  5338. Left justify and remove leading blanks from
  5339. .IR value .
  5340. If
  5341. .I n\^
  5342. is non-zero it defines the width
  5343. of the field,
  5344. otherwise it is determined by the width of the value of
  5345. first assignment.
  5346. When the variable is assigned to, it is
  5347. filled on the right with blanks or truncated, if necessary, to
  5348. fit into the field.
  5349. The
  5350. .B \-R
  5351. option is turned off.
  5352. .TP
  5353. .B \-R
  5354. Right justify and fill with leading blanks.
  5355. If
  5356. .I n\^
  5357. is non-zero it defines the width
  5358. of the field,
  5359. otherwise it is determined by the width of the value of
  5360. first assignment.
  5361. The field is left filled with blanks or
  5362. truncated from the end if the
  5363. variable is reassigned.
  5364. The
  5365. .B \-L
  5366. option is turned off.
  5367. .TP
  5368. .B \-Z
  5369. Right justify and fill with leading zeros if
  5370. the first non-blank character is a digit and the
  5371. .B \-L
  5372. option has not been set.
  5373. Remove leading zeros if the
  5374. .B \-L
  5375. option is also set.
  5376. If
  5377. .I n\^
  5378. is non-zero it defines the width
  5379. of the field,
  5380. otherwise it is determined by the width of the value of
  5381. first assignment.
  5382. .TP
  5383. .B \-f
  5384. The names refer to function names rather than
  5385. variable names.
  5386. No assignments can be made and the only other
  5387. valid options are
  5388. .BR \-t ,
  5389. .B \-u
  5390. and
  5391. .BR \-x .
  5392. The option
  5393. .B \-t
  5394. turns on execution tracing for this function.
  5395. The option
  5396. .B \-u
  5397. causes this function to be marked undefined.
  5398. The
  5399. .SM
  5400. .B FPATH
  5401. variable will be searched to find the function definition
  5402. when the function is referenced.
  5403. .TP
  5404. .B \-i
  5405. Declares
  5406. .I vname\^
  5407. to be represented internally as integer.
  5408. The right hand side of an assignment is evaluated as an
  5409. arithmetic expression when assigning to an integer.
  5410. If
  5411. .I n\^
  5412. is non-zero it defines the output arithmetic base,
  5413. otherwise the the output base will be ten.
  5414. .TP
  5415. .B \-l
  5416. All upper-case characters are
  5417. converted to lower-case.
  5418. The upper-case option,
  5419. .B \-u
  5420. is turned off.
  5421. .TP
  5422. .B \-n
  5423. Declares
  5424. .I vname\^
  5425. to be a reference to the variable whose name is
  5426. defined by the value of variable
  5427. .IR vname .
  5428. This is usually used to reference a variable inside
  5429. a function whose name has been passed as an argument.
  5430. .TP
  5431. .B \-r
  5432. The given
  5433. .IR vname s
  5434. are marked
  5435. readonly and these
  5436. names cannot be changed
  5437. by subsequent assignment.
  5438. .TP
  5439. .B \-t
  5440. Tags the variables.
  5441. Tags are user definable and have no special
  5442. meaning to the shell.
  5443. .TP
  5444. .B \-u
  5445. All lower-case characters are converted
  5446. to upper-case characters.
  5447. The lower-case option,
  5448. .BR \-l ,
  5449. is turned off.
  5450. .TP
  5451. .B \-x
  5452. The given
  5453. .IR vname s
  5454. are marked for automatic
  5455. export to the
  5456. .I environment\^
  5457. of subsequently-executed commands.
  5458. Variables whose names contain a \fB\s+2.\s-2\fP
  5459. can not be exported.
  5460. .PD
  5461. .PP
  5462. The
  5463. .B \-i
  5464. attribute can not be specified along with
  5465. .BR \-R ,
  5466. .BR \-L ,
  5467. .BR \-Z ,
  5468. or
  5469. .BR \-f .
  5470. .PP
  5471. Using
  5472. .B \+
  5473. rather than
  5474. .B \-
  5475. causes these options to be turned off.
  5476. If no
  5477. .I vname\^
  5478. arguments are given
  5479. a list of
  5480. .I vnames\^
  5481. (and optionally the
  5482. .IR values\^ )
  5483. of the
  5484. .I variables\^
  5485. is printed.
  5486. (Using
  5487. .B \+
  5488. rather than
  5489. .B \-
  5490. keeps the
  5491. values from being printed.)
  5492. The
  5493. .B \-p
  5494. option causes
  5495. .B typeset
  5496. followed by the the option letters
  5497. to be printed before each name
  5498. rather than the names of the options.
  5499. If any option other than
  5500. .B \-p
  5501. is given,
  5502. only those variables
  5503. which have all of the given
  5504. options are printed.
  5505. Otherwise, the
  5506. .IR vname s
  5507. and
  5508. .I attributes\^
  5509. of all
  5510. .I variables\^
  5511. are printed.
  5512. .RE
  5513. .TP
  5514. \f3ulimit\fP \*(OK \f3\-HSacdfmnpstv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
  5515. Set or display a resource limit.
  5516. The available resources limits are listed below.
  5517. Many systems do not contain one or more of these limits.
  5518. The limit for a specified resource is set when
  5519. .I limit\^
  5520. is specified.
  5521. The value of
  5522. .I limit\^
  5523. can be a number in the unit specified below with each resource,
  5524. or the value
  5525. .BR unlimited .
  5526. The
  5527. .B \-H
  5528. and
  5529. .B \-S
  5530. options specify whether the hard limit or the
  5531. soft limit for the given resource is set.
  5532. A hard limit cannot be increased once it is set. A soft
  5533. limit can be increased up to the value of the hard limit.
  5534. If neither the
  5535. .B H
  5536. or
  5537. .B S
  5538. options is specified, the limit applies to both.
  5539. The current resource limit is printed when
  5540. .I limit\^
  5541. is omitted.
  5542. In this case the soft limit is printed unless
  5543. .B H
  5544. is specified.
  5545. When more that one resource is specified, then the limit
  5546. name and unit is printed before the value.
  5547. .RS
  5548. .PD 0
  5549. .TP
  5550. .B \-a
  5551. Lists all of the current resource limits.
  5552. .TP
  5553. .B \-c
  5554. The number of 512-byte blocks on the size of core dumps.
  5555. .TP
  5556. .B \-d
  5557. The number of K-bytes on the size of the data area.
  5558. .TP
  5559. .B \-f
  5560. The number of 512-byte blocks on files that can be written the
  5561. current process or by child processes (files of any size may be read).
  5562. .TP
  5563. .B \-m
  5564. The number of K-bytes on the size of physical memory.
  5565. .TP
  5566. .B \-n
  5567. The number of file descriptors plus 1.
  5568. .TP
  5569. .B \-p
  5570. The number of 512-byte blocks for pipe buffering.
  5571. .TP
  5572. .B \-s
  5573. The number of K-bytes on the size of the stack area.
  5574. .TP
  5575. .B \-t
  5576. The number of seconds to be used by each process.
  5577. .TP
  5578. .B \-v
  5579. The number of K-bytes for virtual memory.
  5580. .PD
  5581. .PP
  5582. If no option is given,
  5583. .B \-f
  5584. is assumed.
  5585. .RE
  5586. .TP
  5587. \f3umask\fP \*(OK \f3\-S\fP \*(CK \*(OK \f2mask\^\fP \*(CK
  5588. The user file-creation mask is set to
  5589. .I mask\^
  5590. (see
  5591. .IR umask (2)).
  5592. .I mask
  5593. can either be an octal number or
  5594. a symbolic value as described in
  5595. .IR chmod (1).
  5596. If a symbolic value is given,
  5597. the new
  5598. umask value is the complement of the result of
  5599. applying
  5600. .I mask\^
  5601. to the complement of the previous umask value.
  5602. If
  5603. .I mask\^
  5604. is omitted, the current value of the mask is printed.
  5605. The
  5606. .B \-S
  5607. option causes the mode to be printed as a symbolic
  5608. value. Otherwise, the
  5609. mask is printed in octal.
  5610. .TP
  5611. \(dg \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|.
  5612. The
  5613. .I aliases\^
  5614. given by the list of
  5615. .IR name s
  5616. are removed from the
  5617. .I alias\^
  5618. list.
  5619. The
  5620. .B \-a
  5621. option causes all the
  5622. aliases to be unset.
  5623. .TP
  5624. \(dg\f3unset\fP \*(OK \f3\-fv\fP \*(CK \f2vname\^\fP .\|.\|.
  5625. The variables given by the list of
  5626. .IR vname s
  5627. are unassigned,
  5628. i.e.,
  5629. their values and attributes are erased.
  5630. Readonly variables cannot be unset.
  5631. If the
  5632. .B \-f
  5633. option
  5634. is set, then the names refer to
  5635. .I function\^
  5636. names.
  5637. If the
  5638. .B \-v
  5639. option is set, then the names refer to
  5640. .I variable\^
  5641. names.
  5642. The default is equivalent to
  5643. .BR \-v .
  5644. Unsetting
  5645. .SM
  5646. .BR ERRNO ,
  5647. .SM
  5648. .BR LINENO ,
  5649. .SM
  5650. .BR MAILCHECK ,
  5651. .SM
  5652. .BR OPTARG ,
  5653. .SM
  5654. .BR OPTIND ,
  5655. .SM
  5656. .BR RANDOM ,
  5657. .SM
  5658. .BR SECONDS ,
  5659. .SM
  5660. .BR TMOUT ,
  5661. and
  5662. .SM
  5663. .B _
  5664. removes their special meaning even if they are
  5665. subsequently assigned to.
  5666. .TP
  5667. \f3wait\fP \*(OK \f2job\^\fP .\|.\|. \*(CK
  5668. Wait for the specified
  5669. .I job
  5670. and
  5671. report its termination status.
  5672. If
  5673. .I job\^
  5674. is not given then all currently active child processes are waited for.
  5675. The exit status from this command is that of
  5676. the last process waited for.
  5677. See
  5678. .I Jobs
  5679. for a description of the format of
  5680. .IR job .
  5681. .TP
  5682. \f3whence\fP \*(OK \f3\-apv\fP \*(CK \f2name\^\fP .\|.\|.
  5683. For each
  5684. .IR name ,
  5685. indicate how it
  5686. would be interpreted if used as a command name.
  5687. .P
  5688. The
  5689. .B \-v
  5690. option
  5691. produces a more verbose report.
  5692. .P
  5693. The
  5694. .B \-p
  5695. option
  5696. does a path search for
  5697. .I name\^
  5698. even if name is an alias, a function, or a reserved word.
  5699. The
  5700. .B \-a
  5701. is similar to the
  5702. .B \-v
  5703. option but causes
  5704. all interpretations of the given name to be reported.
  5705. .SS Invocation.
  5706. If the shell is invoked by
  5707. .IR exec (2),
  5708. and the first character of argument zero
  5709. .RB ( $0 )
  5710. is
  5711. .BR \- ,
  5712. then the shell is assumed to be a
  5713. .I login
  5714. shell and
  5715. commands are read from
  5716. .B /etc/profile
  5717. and then from either
  5718. .B .profile
  5719. in the current directory or
  5720. .BR \s-1$HOME\s+1/.profile ,
  5721. if either file exists.
  5722. Next, commands are read from
  5723. the file named by
  5724. performing parameter expansion, command substitution,
  5725. and arithmetic substitution on
  5726. the value of the environment variable
  5727. .SM
  5728. .B ENV
  5729. if the file exists.
  5730. If the
  5731. .B \-s
  5732. option is not present and
  5733. .I arg\^
  5734. is, then a path search is performed on the first
  5735. .I arg\^
  5736. to determine the name of the script to execute.
  5737. The script
  5738. .I arg\^
  5739. must have read permission and any
  5740. .I setuid
  5741. and
  5742. .I getgid
  5743. settings will be ignored.
  5744. If the script is not found on the path,
  5745. .I arg\^
  5746. is processed as if it named a built-in command or function.
  5747. Commands are then read as described below;
  5748. the following option are interpreted by the shell
  5749. when it is invoked:
  5750. .PP
  5751. .PD 0
  5752. .TP 10
  5753. .BI \-c
  5754. If the
  5755. .B \-c
  5756. option is present then
  5757. commands are read from the first
  5758. .IR arg .
  5759. Any remaining arguments become
  5760. position parameters starting at
  5761. .B 0 .
  5762. .TP
  5763. .B \-s
  5764. If the
  5765. .B \-s
  5766. option is present or if no
  5767. arguments remain
  5768. then commands are read from the standard input.
  5769. Shell output,
  5770. except for the output of the
  5771. .I Special Commands\^
  5772. listed above,
  5773. is written to
  5774. file descriptor 2.
  5775. .TP
  5776. .B \-i
  5777. If the
  5778. .B \-i
  5779. option is present or
  5780. if the shell input and output are attached to a terminal (as told by
  5781. .IR ioctl (2))
  5782. then this shell is
  5783. .IR interactive .
  5784. In this case \s-1TERM\s+1 is ignored (so that \f3kill 0\fP
  5785. does not kill an interactive shell) and \s-1INTR\s+1 is caught and ignored
  5786. (so that
  5787. .B wait
  5788. is interruptible).
  5789. In all cases, \s-1QUIT\s+1 is ignored by the shell.
  5790. .TP
  5791. .B \-r
  5792. If the
  5793. .B \-r
  5794. option is present the shell is a restricted shell.
  5795. .PD
  5796. .PP
  5797. The
  5798. .B \-I
  5799. .I filename\^
  5800. option is used
  5801. to generate a cross reference database
  5802. that can be used by a separate utility
  5803. to find definitions and references for variables and commands.
  5804. .PP
  5805. The remaining options and arguments are described under the
  5806. .B set
  5807. command above.
  5808. An optional
  5809. .B \-
  5810. as the first argument is ignored.
  5811. .if \nZ=0 \{.SS Rsh Only.
  5812. .I Rsh\}
  5813. .if \nZ=1 \{.SS Rksh Only.
  5814. .I Rksh\}
  5815. is used to set up login names and execution environments whose
  5816. capabilities are more controlled than those of the standard shell.
  5817. The actions of
  5818. .if \nZ=0 .B rsh\^
  5819. .if \nZ=1 .B rksh\^
  5820. are identical to those of
  5821. .if \nZ=0 .BR sh\^ ,
  5822. .if \nZ=1 .BR ksh\^ ,
  5823. except that the following are disallowed:
  5824. .RS
  5825. .PD 0
  5826. .PP
  5827. changing directory (see
  5828. .IR cd (1)),
  5829. .br
  5830. setting or unsetting the value or attributes of
  5831. .SM
  5832. .BR SHELL ,
  5833. .SM
  5834. .BR ENV ,
  5835. or
  5836. .SM
  5837. .BR PATH\*S,
  5838. .br
  5839. specifying path or
  5840. command names containing
  5841. .BR / ,
  5842. .br
  5843. redirecting output
  5844. .RB ( > ,
  5845. .BR >| ,
  5846. .BR <> ,
  5847. and
  5848. .BR >> ).
  5849. .PD
  5850. .RE
  5851. .PP
  5852. The restrictions above are enforced
  5853. after \f3.profile\fP and the
  5854. .SM
  5855. .B ENV
  5856. files are interpreted.
  5857. .PP
  5858. When a command to be executed is found to be a shell procedure,
  5859. .if \nZ=0 \{.B rsh\^
  5860. invokes
  5861. .I sh\^\}
  5862. .if \nZ=1 \{.B rksh\^
  5863. invokes
  5864. .I ksh\^\}
  5865. to execute it.
  5866. Thus, it is possible to provide to the end-user shell procedures
  5867. that have access to the full power of
  5868. the standard shell,
  5869. while imposing a limited menu of commands;
  5870. this scheme assumes that the end-user does not have write and
  5871. execute permissions in the same directory.
  5872. .PP
  5873. The net effect of these rules is that the writer of the
  5874. .B .profile
  5875. has complete control over user actions,
  5876. by performing guaranteed setup actions
  5877. and leaving the user in an appropriate directory
  5878. (probably
  5879. .I not\^
  5880. the login directory).
  5881. .PP
  5882. The system administrator often sets up a directory
  5883. of commands
  5884. (i.e.,
  5885. .BR /usr/rbin )
  5886. that can be safely invoked by
  5887. .if \nZ=0 .BR rsh .
  5888. .if \nZ=1 .BR rksh .
  5889. .SH EXIT STATUS
  5890. Errors detected by the shell, such as syntax errors,
  5891. cause the shell
  5892. to return a non-zero exit status.
  5893. Otherwise, the shell returns the exit status of
  5894. the last command executed (see also the
  5895. .B exit
  5896. command above).
  5897. If the shell is being used non-interactively
  5898. then execution of the shell file is abandoned.
  5899. Run time errors detected by the shell are reported by
  5900. printing the command or function name and the error condition.
  5901. If the line number that the error occurred on is greater than one,
  5902. then the line number is also printed in square brackets
  5903. .RB ( "[]" )
  5904. after the command or function name.
  5905. .SH FILES
  5906. /etc/passwd
  5907. .br
  5908. /etc/profile
  5909. .br
  5910. /etc/suid_profile
  5911. .br
  5912. \s-1$HOME\s+1/\f3.\fPprofile
  5913. .br
  5914. /tmp/sh\(**
  5915. .br
  5916. /dev/null
  5917. .SH SEE ALSO
  5918. cat(1),
  5919. cd(1),
  5920. chmod(1),
  5921. cut(1),
  5922. echo(1),
  5923. emacs(1),
  5924. env(1),
  5925. gmacs(1),
  5926. newgrp(1),
  5927. stty(1),
  5928. test(1),
  5929. umask(1),
  5930. vi(1),
  5931. dup(2),
  5932. exec(2),
  5933. fork(2),
  5934. ioctl(2),
  5935. lseek(2),
  5936. paste(1),
  5937. pipe(2),
  5938. umask(2),
  5939. ulimit(2),
  5940. wait(2),
  5941. rand(3),
  5942. a.out(5),
  5943. profile(5),
  5944. environ(7).
  5945. .PP
  5946. Morris I. Bolsky and David G. Korn,
  5947. .IR "The KornShell Command and Programming Language" ,
  5948. Prentice Hall, 1989, ISBN 0-13-516972-0.
  5949. .SH CAVEATS
  5950. .PP
  5951. If a command
  5952. is executed, and then a command with the same name is
  5953. installed in a directory in the search path before the directory where the
  5954. original command was found, the shell will continue to
  5955. .I exec\^
  5956. the original command.
  5957. Use the
  5958. .B \-t
  5959. option of the
  5960. .B alias\^
  5961. command to correct this situation.
  5962. .PP
  5963. Some very old shell scripts contain a
  5964. .B ^
  5965. as a synonym for the pipe character
  5966. .BR \(bv .
  5967. .PP
  5968. Using the
  5969. .B hist\^
  5970. built-in command within a compound command will cause the whole
  5971. command to disappear from the history file.
  5972. .PP
  5973. The built-in command \f3\|.\fP \f2file\^\fP
  5974. reads the whole file before any commands are executed.
  5975. Therefore,
  5976. .B alias
  5977. and
  5978. .B unalias
  5979. commands in the file
  5980. will not apply to any commands defined in the file.
  5981. .PP
  5982. Traps are not processed while a job is waiting for a foreground process.
  5983. Thus, a trap on
  5984. .B CHLD
  5985. won't be executed until the foreground job terminates.