'cd-'的行为(两个连字符)

时间:2018-07-08 11:47:11

标签: bash cd

我知道GNU bash, version 4.4.23(1)-release (x86_64-apple-darwin17.5.0)将目录更改为$ OLDPWD。

我在Macbook上使用import com.github.tminglei.slickpg._ trait MyPostgresProfile extends ExPostgresProfile with PgArraySupport with PgDate2Support with PgRangeSupport with PgHStoreSupport //with PgPlayJsonSupport with PgSearchSupport //with PgPostGISSupport with PgNetSupport with PgLTreeSupport { def pgjson = "jsonb" // jsonb support is in postgres 9.4.0 onward; for 9.3.x use "json" // Add back `capabilities.insertOrUpdate` to enable native `upsert` support; for postgres 9.5+ //override protected def computeCapabilities: Set[Capability] = // super.computeCapabilities + JdbcProfile.capabilities.insertOrUpdate override val api = MyAPI object MyAPI extends API with ArrayImplicits with DateTimeImplicits // with JsonImplicits with NetImplicits with LTreeImplicits with RangeImplicits with HStoreImplicits with SearchImplicits with SearchAssistants { implicit val intListTypeMapper = new SimpleArrayJdbcType[Int]("integer").to(_.toList) implicit val intListListTypeMapper = new AdvancedArrayJdbcType[List[Int]]("integer[]", utils.SimpleArrayUtils.fromString[List[Int]](s => scala.util.Try(s.substring(5, s.length - 1).split(",").map(_.trim.toInt).toList).getOrElse(List()) )(_).orNull, utils.SimpleArrayUtils.mkString[List[Int]](_.toString) ).to(_.toList) } } object MyPostgresProfile extends MyPostgresProfile import MyPostgresProfile.api._ case class Something(name: String, bbox: List[List[Int]]) class SomethingTable(tag: Tag) extends Table[Something](tag, "Something") { def name = column[String]("name", O.PrimaryKey) def bbox = column[List[List[Int]]]("bbox") def * = (name, bbox) <> (Something.tupled, Something.unapply) } val query = TableQuery[SomethingTable]

“ cd-”似乎与“ cd〜-”具有相同的行为。

为什么?

2 个答案:

答案 0 :(得分:4)

使用重击--用于指定命令选项的结尾。

所以cd --的意思是cd

cd(不带参数)将当前目录更改为您的主目录(例如cd ~)。

将您带到上一个PWD的事实是一个巧合。

答案 1 :(得分:3)

那是不正确的。 cd --会更改为您的主目录,就像cd一样。考虑cd --为纯cd,其中没有选项,也没有给出参数。另请参见https://unix.stackexchange.com/a/11382