github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/cmds/exp/ash/cd.go (about) 1 // Copyright 2012 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // our first builtin: cd 6 package main 7 8 import ( 9 "errors" 10 "os" 11 ) 12 13 func init() { 14 addBuiltIn("cd", cd) 15 } 16 17 func cd(c *Command) error { 18 if len(c.argv) != 1 { 19 return errors.New("usage: cd one-path") 20 } 21 22 err := os.Chdir(c.argv[0]) 23 return err 24 }